Sha256: df0881b3f800b58c6520402356c0d7843bd63ab0ef601a624532b63d4ebb0e8c

Contents?: true

Size: 731 Bytes

Versions: 1

Compression:

Stored size: 731 Bytes

Contents

module Timber
  module Contexts
    class Logger < Context
      ROOT_KEY = :logger.freeze
      VERSION = 1.freeze
      LEVEL_MAP = {
        0 => "debug",
        1 => "info",
        2 => "warn",
        3 => "error",
        4 => "fatal"
      }
      UNKNOWN_LEVEL = "unknown"

      attr_reader :level, :progname

      def initialize(level, progname)
        @level = LEVEL_MAP[level] || UNKNOWN_LEVEL
        @progname = progname
        super()
      end

      private
        def json_payload
          @json_payload ||= Macros::DeepMerger.merge({
            # order is relevant for logfmt styling
            :level => level,
            :progname => progname
          }, super).freeze
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 lib/timber/contexts/logger.rb