Class: SemanticLogger::Formatters::Json
- Defined in:
- lib/semantic_logger/formatters/json.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call(log, logger) ⇒ Object
Returns log messages in JSON format.
-
#initialize(options = {}) ⇒ Json
constructor
Default JSON time format is ISO8601.
Methods inherited from Base
#fast_tag, #level, #level=, #measure, #payload, #pop_tags, #push_tags, #silence, #tagged, #tags, #with_payload
Constructor Details
#initialize(options = {}) ⇒ Json
Default JSON time format is ISO8601
6 7 8 9 10 |
# File 'lib/semantic_logger/formatters/json.rb', line 6 def initialize( = {}) = .dup [:time_format] = :iso_8601 unless .has_key?(:time_format) super() end |
Instance Method Details
#call(log, logger) ⇒ Object
Returns log messages in JSON format
13 14 15 16 17 18 |
# File 'lib/semantic_logger/formatters/json.rb', line 13 def call(log, logger) h = super(log, logger) h.delete(:time) h[:timestamp] = format_time(log.time) h.to_json end |