Module: Hoodoo::Logger::FlattenerMixin

Included in:
FileWriter, StreamWriter
Defined in:
lib/hoodoo/logger/flattener_mixin.rb

Overview

This mixin is used by custom logger subclasses and defines a single method, Hoodoo::Logger::FlattenerMixin#flatten, which takes structured log data and turns it into a single line of output including ISO 8601 time and date in local server time zone (since that makes log analysis easier for humans working in non-UTC time zone regions).

Using this is of course entirely optional, but if you do use it, you will be ensuring consistent non-structured log output across any non-structured writers.

Instance Method Summary collapse

Instance Method Details

#flatten(log_level, component, code, data) ⇒ Object

Take the parameters from Hoodoo::Logger::WriterMixin#report and return a single line string representing the “flattened” log data.



31
32
33
# File 'lib/hoodoo/logger/flattener_mixin.rb', line 31

def flatten( log_level, component, code, data )
  "#{ log_level.to_s.upcase } [#{ Hoodoo::Utilities.standard_datetime( Time.now ) }] #{ component } - #{ code }: #{ data.inspect }"
end