Class Lumberjack::Formatter
In: lib/lumberjack/formatter/string_formatter.rb
lib/lumberjack/formatter/inspect_formatter.rb
lib/lumberjack/formatter/pretty_print_formatter.rb
lib/lumberjack/formatter/exception_formatter.rb
lib/lumberjack/formatter.rb
Parent: Object

This class controls the conversion of log entry messages into strings. This allows you to log any object you want and have the logging system worry about converting it into a string.

Formats are added to a Formatter by associating them with a class using the add method. Formats are any object that responds to the call method.

By default, all object will be converted to strings using their inspect method except for Strings and Exceptions. Strings are not converted and Exceptions are converted using the ExceptionFormatter.

Methods

add   call   format   new   remove  

Classes and Modules

Class Lumberjack::Formatter::ExceptionFormatter
Class Lumberjack::Formatter::InspectFormatter
Class Lumberjack::Formatter::PrettyPrintFormatter
Class Lumberjack::Formatter::StringFormatter

Public Class methods

Public Instance methods

Add a formatter for a class. The formatter can be specified as either an object that responds to the call method or as a symbol representing one of the predefined formatters, or as a block to the method call.

The predefined formatters are: :inspect, :string, :exception, and :pretty_print.

Examples

  # Use a predefined formatter
  formatter.add(MyClass, :pretty_print)

  # Pass in a formatter object
  formatter.add(MyClass, Lumberjack::Formatter::PrettyPrintFormatter.new)

  # Use a block
  formatter.add(MyClass){|obj| obj.humanize}

  # Add statements can be chained together
  formatter.add(MyClass, :pretty_print).add(YourClass){|obj| obj.humanize}

Format a message object as a string.

Remove the formatter associated with a class. Remove statements can be chained together.

[Validate]