Class Logging::Layout
In: lib/logging/layout.rb
Parent: Object

The Layout class provides methods for formatting log events into a string representation. Layouts are used by Appenders to format log events before writing them to the logging destination.

All other Layouts inherit from this class which provides stub methods. Each subclass should provide a format method. A layout can be used by more than one Appender so all the methods need to be thread safe.

Methods

footer   format   format_obj   header   new   try_yaml  

Public Class methods

Creates a new layout that will format objects as strings using the given :format_as style. This can be one of :string, :inspect, or :yaml. These formatting commands map to the following object methods:

  • :string => to_s
  • :inspect => inspect
  • :yaml => to_yaml

If the format is not specified then the global object format is used (see Logging#format_as). If the global object format is not specified then :string is used.

Public Instance methods

Returns a footer string to be used at the end of a logging appender.

Returns a string representation of the given logging event. It is up to subclasses to implement this method.

Return a string representation of the given object. Depending upon the configuration of the logger system the format will be an inspect based representation or a yaml based representation.

Returns a header string to be used at the beginning of a logging appender.

Attempt to format the obj using yaml, but fall back to inspect style formatting if yaml fails.

[Validate]