lib/logging/layout.rb in logging-0.5.3 vs lib/logging/layout.rb in logging-0.6.0
- old
+ new
@@ -1,6 +1,6 @@
-# $Id: layout.rb 52 2007-11-27 23:53:23Z tim_pease $
+# $Id: layout.rb 62 2007-12-22 20:37:05Z tim_pease $
require 'yaml'
require 'logging'
module Logging
@@ -30,11 +30,13 @@
# If the format is not specified then the global object format is used
# (see Logging#format_as). If the global object format is not specified
# then <tt>:string</tt> is used.
#
def initialize( opts = {} )
- f = opts[:format_as] || opts['format_as']
- f ||= ::Logging::OBJ_FORMAT if ::Logging.const_defined? 'OBJ_FORMAT'
+ default = ::Logging.const_defined?('OBJ_FORMAT') ?
+ ::Logging::OBJ_FORMAT : nil
+
+ f = opts.getopt(:format_as, default)
f = f.intern if f.instance_of? String
@obj_format = case f
when :inspect, :yaml; f
else :string end