Sha256: cd43fc91c26dbadce87749e005b05e48bfefe63d94f56635d7202687d8c94342

Contents?: true

Size: 536 Bytes

Versions: 7

Compression:

Stored size: 536 Bytes

Contents

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)
      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
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
semantic_logger-4.0.0 lib/semantic_logger/formatters/json.rb
semantic_logger-4.0.0.rc1 lib/semantic_logger/formatters/json.rb
semantic_logger-4.0.0.beta2 lib/semantic_logger/formatters/json.rb
semantic_logger-4.0.0.beta1 lib/semantic_logger/formatters/json.rb
semantic_logger-3.4.1 lib/semantic_logger/formatters/json.rb
semantic_logger-3.4.0 lib/semantic_logger/formatters/json.rb
semantic_logger-3.3.0 lib/semantic_logger/formatters/json.rb