Sha256: c65056c7fc6c856d1a02dd65cbfee96497e186f915c2cfce4045ae7d77233d44

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

require 'json'
module SemanticLogger
  module Formatters
    class Json < Raw
      # Default JSON time format is ISO8601
      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)
        super(log, logger).to_json
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
semantic_logger-4.1.1 lib/semantic_logger/formatters/json.rb
semantic_logger-4.1.0 lib/semantic_logger/formatters/json.rb