Class: Gallus::Format::SimpleLog

Inherits:
Object
  • Object
show all
Defined in:
lib/gallus/format/simple_log.rb

Overview

Public: Simple because of implementation, not because of the output. It’s default log line that contains most information needed. Everything presented in a compact and easy to parse form. Example:

"I @ 2016-01-15T16:32:56+01:00Z $ Foo > Hello World; foo=1 bar=2"

Instance Method Summary collapse

Constructor Details

#initialize(serialization = Serialization::Inspect) ⇒ SimpleLog

Returns a new instance of SimpleLog.



8
9
10
# File 'lib/gallus/format/simple_log.rb', line 8

def initialize(serialization = Serialization::Inspect)
  @serialization = serialization
end

Instance Method Details

#call(event) ⇒ Object



12
13
14
15
# File 'lib/gallus/format/simple_log.rb', line 12

def call(event)
  message = [ event.message, @serialization.call(event.payload) ].compact.join('; ')
  format("%s @ %s $ %s > %s", event.level.name[0], event.recorded_at.iso8601, event.logger, message)
end