Class: ElasticGraph::Support::Logger::JSONAwareFormatter
- Inherits:
-
Object
- Object
- ElasticGraph::Support::Logger::JSONAwareFormatter
- Defined in:
- lib/elastic_graph/support/logger.rb
Instance Method Summary collapse
- #call(severity, datetime, progname, msg) ⇒ Object
-
#initialize ⇒ JSONAwareFormatter
constructor
A new instance of JSONAwareFormatter.
Constructor Details
#initialize ⇒ JSONAwareFormatter
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 |