Class: Klogger::Formatters::JSON

Inherits:
Abstract
  • Object
show all
Defined in:
lib/klogger/formatters/json.rb

Instance Method Summary collapse

Methods inherited from Abstract

#initialize

Constructor Details

This class inherits a constructor from Klogger::Abstract

Instance Method Details

#call(_severity, _time, _progname, payload) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/klogger/formatters/json.rb', line 11

def call(_severity, _time, _progname, payload)
  json = payload.to_json
  if @highlight
    json.gsub!('","', '", "')
    json.gsub!(/\A{/, '{ ')
    json.gsub!(/\}\z/, ' }')
    json = JSONHighlighter.highlight(json)
  end
  json + "\n"
end