lib/logging/layout.rb in logging-0.5.1 vs lib/logging/layout.rb in logging-0.5.2
- old
+ new
@@ -1,6 +1,6 @@
-# $Id: layout.rb 37 2007-10-26 19:12:44Z tim_pease $
+# $Id: layout.rb 52 2007-11-27 23:53:23Z tim_pease $
require 'yaml'
require 'logging'
module Logging
@@ -35,11 +35,11 @@
f = opts[:format_as] || opts['format_as']
f ||= ::Logging::OBJ_FORMAT if ::Logging.const_defined? 'OBJ_FORMAT'
f = f.intern if f.instance_of? String
@obj_format = case f
- when :inspect, :yaml: f
+ when :inspect, :yaml; f
else :string end
end
# call-seq:
# format( event )
@@ -74,22 +74,22 @@
# the configuration of the logger system the format will be an +inspect+
# based represenation or a +yaml+ based representation.
#
def format_obj( obj )
case obj
- when String: obj
- when Exception:
+ when String; obj
+ when Exception
str = "<#{obj.class.name}> #{obj.message}"
unless obj.backtrace.nil?
str << "\n\t" << obj.backtrace.join("\n\t")
end
str
- when nil: "<#{obj.class.name}> nil"
+ when nil; "<#{obj.class.name}> nil"
else
str = "<#{obj.class.name}> "
str << case @obj_format
- when :inspect: obj.inspect
- when :yaml: "\n#{obj.to_yaml}"
+ when :inspect; obj.inspect
+ when :yaml; "\n#{obj.to_yaml}"
else obj.to_s end
str
end
end