BasicFormatter produces output like this:
WARN loggername: I dropped my Wookie!
Or like this if trace is on:
WARN loggername(file.rb at 12): Hot potato!
Also, it will pretty-print any Exception it gets and inspect everything else.
Hash arguments include:
depth |
How many lines of the stacktrace to display. |
# File lib/log4r/formatter/formatter.rb, line 55 def format(event) buff = sprintf(@@basicformat, MaxLevelLength, LNAMES[event.level], event.name) buff << (event.tracer.nil? ? "" : "(#{event.tracer[0]})") + ": " buff << format_object(event.data) + "\n" buff end
Formats data according to its class:
String |
Prints it out as normal. |
Exception |
Produces output similar to command-line exceptions. |
Prints the type of object, then the output of inspect. An example -- Array: [1, 2, 3] |
# File lib/log4r/formatter/formatter.rb, line 70 def format_object(obj) if obj.kind_of? Exception return "Caught #{obj.class}: #{obj.message}\n\t" + (obj.backtrace.nil? ? [] : obj.backtrace[0...@depth]).join("\n\t") elsif obj.kind_of? String return obj else # inspect the object return "#{obj.class}: #{obj.inspect}" end end
Generated with the Darkfish Rdoc Generator 2.