Class: Gallus::Format::SimpleConsole

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

Overview

Public: This console log format is used for command line apps. Instead of using puts-es and write-s to display stuff use logger! INFO level will be displayed without prefixes, as is - just message and context info. Other levels will be prefixed with level name. Example:

Hello, this is info message
ERROR: Upps, something went wrong; foo="Bar"
Another info message
DEBUG: Here's debug information
...

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of SimpleConsole.



14
15
16
# File 'lib/gallus/format/simple_console.rb', line 14

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

Instance Method Details

#call(event) ⇒ Object



18
19
20
21
22
# File 'lib/gallus/format/simple_console.rb', line 18

def call(event)
  parts = [ [ event.message, @serialization.call(event.payload) ].compact.join('; ') ]
  parts.unshift(format("%s:", event.level.name)) unless event.level == Level::INFO
  parts.compact.join(' ')
end