Class: Yell::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/yell/formatter.rb

Overview

The Formatter provides a handle to configure your log message style.

Constant Summary collapse

PatternTable =

:nodoc:

{
  "m" => "event.message",                 # Message
  "l" => "event.level[0]",                # Level (short), e.g.'I', 'W'
  "L" => "event.level",                   # Level, e.g. 'INFO', 'WARN'
  "d" => "date(event)",                   # ISO8601 Timestamp
  "p" => "Process.pid",                   # PID
  "h" => "hostname",                      # Hostname
  "F" => "event.file",                    # Path with filename where the logger was called
  "f" => "File.basename(event.file)",     # Filename where the loger was called
  "M" => "event.method",                  # Method name where the logger was called
  "n" => "event.line"                     # Line where the logger was called
}
PatternRegexp =

:nodoc:

/([^%]*)(%\d*)?([#{PatternTable.keys.join}])?(.*)/

Instance Method Summary collapse

Constructor Details

#initialize(pattern = nil, date_pattern = nil) ⇒ Formatter

Returns a new instance of Formatter.



71
72
73
74
75
76
# File 'lib/yell/formatter.rb', line 71

def initialize( pattern = nil, date_pattern = nil )
  @pattern      = pattern || Yell::DefaultFormat
  @date_pattern = date_pattern

  define!
end