Class: Logging::Layouts::Basic

Inherits:
Logging::Layout show all
Defined in:
lib/logging/layouts/basic.rb

Overview

The Basic layout class provides methods for simple formatting of log events. The resulting string follows the format below.

LEVEL  LoggerName : log message

LEVEL is the log level of the event. LoggerName is the name of the logger that generated the event. log message is the message or object that was passed to the logger. If multiple message or objects were passed to the logger then each will be printed on its own line with the format show above.

Instance Attribute Summary

Attributes inherited from Logging::Layout

#backtrace, #cause_depth, #utc_offset

Instance Method Summary collapse

Methods inherited from Logging::Layout

#apply_utc_offset, #footer, #format_cause, #format_cause_backtrace, #format_obj, #header, #initialize, #try_json, #try_yaml

Constructor Details

This class inherits a constructor from Logging::Layout

Instance Method Details

#format(event) ⇒ Object

call-seq:

format( event )

Returns a string representation of the given logging event. See the class documentation for details about the formatting used.


30
31
32
33
34
# File 'lib/logging/layouts/basic.rb', line 30

def format( event )
  obj = format_obj(event.data)
  sprintf("%*s  %s : %s\n", ::Logging::MAX_LEVEL_LENGTH,
          ::Logging::LNAMES[event.level], event.logger, obj)
end