Sha256: 85cc2c8a8d8f7f6f9af510e3ef30b9e8093aee9cc066c85bd82f1ead0e29eb89

Contents?: true

Size: 682 Bytes

Versions: 7

Compression:

Stored size: 682 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
        when 'ANY'
          70
        else # DEBUG
          20
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ougai-1.4.1 lib/ougai/formatters/bunyan.rb
ougai-1.4.0 lib/ougai/formatters/bunyan.rb
ougai-1.3.0 lib/ougai/formatters/bunyan.rb
ougai-1.2.0 lib/ougai/formatters/bunyan.rb
ougai-1.1.0 lib/ougai/formatters/bunyan.rb
ougai-1.0.0 lib/ougai/formatters/bunyan.rb
ougai-0.9.0 lib/ougai/formatters/bunyan.rb