lib/semantic_logger/formatters/json.rb in semantic_logger-4.0.0 vs lib/semantic_logger/formatters/json.rb in semantic_logger-4.1.0

- old
+ new

@@ -1,21 +1,20 @@ require 'json' module SemanticLogger module Formatters class Json < Raw # Default JSON time format is ISO8601 - def initialize(options = {}) - options = options.dup - options[:time_format] = :iso_8601 unless options.has_key?(:time_format) - super(options) + def initialize(time_format: :iso_8601, log_host: true, log_application: true) + super(time_format: time_format, log_host: log_host, log_application: log_application) end + def time + hash[:timestamp] = format_time(log.time) + end + # Returns log messages in JSON format def call(log, logger) - h = super(log, logger) - h.delete(:time) - h[:timestamp] = format_time(log.time) - h.to_json + super(log, logger).to_json end end end end