Class: ElasticGraph::Support::Logger::JSONAwareFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/elastic_graph/support/logger.rb

Instance Method Summary collapse

Constructor Details

#initializeJSONAwareFormatter

Returns a new instance of JSONAwareFormatter.



33
34
35
# File 'lib/elastic_graph/support/logger.rb', line 33

def initialize
  @original_formatter = ::Logger::Formatter.new
end

Instance Method Details

#call(severity, datetime, progname, msg) ⇒ Object



37
38
39
40
# File 'lib/elastic_graph/support/logger.rb', line 37

def call(severity, datetime, progname, msg)
  msg = msg.is_a?(::Hash) ? ::JSON.generate(msg, space: " ") : msg
  @original_formatter.call(severity, datetime, progname, msg)
end