Class: Log4r::ObjectFormatter

Inherits:
Formatter show all
Defined in:
lib/log4r/formatter/formatter.rb

Overview

Formats objects the same way irb does:

loggername:foo.rb in 12> 
[1, 3, 4]
loggername:foo.rb in 13> 
{1=>"1"}

Strings don’t get inspected. just printed. The trace is optional.

Instance Method Summary collapse

Methods inherited from Formatter

#initialize

Constructor Details

This class inherits a constructor from Log4r::Formatter

Instance Method Details

#format(event) ⇒ Object



96
97
98
99
100
101
# File 'lib/log4r/formatter/formatter.rb', line 96

def format(event)
  buff = event.logger.name
  buff << (event.tracer.nil? ? "" : ":#{event.tracer[0]}") + ">\n"
  buff << (event.data.kind_of?(String) ? event.data : event.data.inspect)
  buff << "\n"
end