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



92
93
94
95
96
97
# File 'lib/log4r/formatter/formatter.rb', line 92

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