Class: Sapience::Formatters::Json
- Defined in:
- lib/sapience/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
#app_name, #default_formatter, #fast_tag, #host, #level, #level=, #payload, #pop_tags, #push_tags, #silence, #tagged, #tags, #with_payload
Methods included from LogMethods
#debug, #debug?, #error, #error!, #error?, #fatal, #fatal!, #fatal?, #info, #info?, #level_to_index, #log_with_exception, #log_with_level, #measure, #measure_debug, #measure_error, #measure_fatal, #measure_info, #measure_trace, #measure_warn, #trace, #trace?, #warn, #warn?
Constructor Details
#initialize(options = {}) ⇒ Json
Default JSON time format is ISO8601
7 8 9 10 11 |
# File 'lib/sapience/formatters/json.rb', line 7 def initialize( = {}) = .dup [:time_format] = :iso_8601 unless .key?(:time_format) super() end |
Instance Method Details
#call(log, logger) ⇒ Object
Returns log messages in JSON format
14 15 16 17 18 19 |
# File 'lib/sapience/formatters/json.rb', line 14 def call(log, logger) h = super(log, logger) h.delete(:time) h[:timestamp] = format_time(log.time) h.to_json end |