Class: Logcraft::LogLayout

Inherits:
Logging::Layout
  • Object
show all
Defined in:
lib/logcraft/log_layout.rb

Instance Method Summary collapse

Constructor Details

#initialize(global_context = {}, options = {}) ⇒ LogLayout



7
8
9
10
# File 'lib/logcraft/log_layout.rb', line 7

def initialize(global_context = {}, options = {})
  @global_context = global_context
  @level_formatter = options.fetch :level_formatter, ->(level) { Logging::LNAMES[level] }
end

Instance Method Details

#format(event) ⇒ Object



12
13
14
15
16
17
# File 'lib/logcraft/log_layout.rb', line 12

def format(event)
  log_entry = background_of(event).merge evaluated_global_context,
                                         dynamic_log_context,
                                         message_from(event.data)
  MultiJson.dump(log_entry) + "\n"
end