Sha256: 834ac0822c137de836a9d1b82ba5b72062b8348b3d4bd2a99843efca906ce90d

Contents?: true

Size: 650 Bytes

Versions: 6

Compression:

Stored size: 650 Bytes

Contents

require 'ougai/formatters/base'
require 'json'

module Ougai
  module Formatters
    class Bunyan < Base
      def call(severity, time, progname, data)
        JSON.generate({
          name: progname || @app_name,
          hostname: @hostname,
          pid: $$,
          level: to_level(severity),
          time: time.iso8601(3),
          v: 0
        }.merge(data)) + "\n"
      end

      def to_level(severity)
        case severity
        when 'INFO'
          30
        when 'WARN'
          40
        when 'ERROR'
          50
        when 'FATAL'
          60
        else # DEBUG
          20
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ougai-0.8.0 lib/ougai/formatters/bunyan.rb
ougai-0.7.4 lib/ougai/formatters/bunyan.rb
ougai-0.7.3 lib/ougai/formatters/bunyan.rb
ougai-0.7.2 lib/ougai/formatters/bunyan.rb
ougai-0.7.1 lib/ougai/formatters/bunyan.rb
ougai-0.7.0 lib/ougai/formatters/bunyan.rb