Sha256: 910e62da5f43bc5fa05183f6f09a1d1ed7ab828870091272b67e2cce1a0e255b

Contents?: true

Size: 1.58 KB

Versions: 69

Compression:

Stored size: 1.58 KB

Contents

require 'ougai/formatters/base'
require 'ougai/formatters/for_json'

module Ougai
  module Formatters
    # A JSON formatter compatible with node-bunyan
    class ConnectFormatter < Base
      include ForJson

      # Intialize a formatter
      # @param [String] app_name application name (execution program name if nil)
      # @param [String] hostname hostname (hostname if nil)
      # @param [Hash] opts the initial values of attributes
      # @option opts [String] :trace_indent (2) the value of trace_indent attribute
      # @option opts [String] :trace_max_lines (100) the value of trace_max_lines attribute
      # @option opts [String] :serialize_backtrace (true) the value of serialize_backtrace attribute
      # @option opts [String] :jsonize (true) the value of jsonize attribute
      # @option opts [String] :with_newline (true) the value of with_newline attribute
      def initialize(app_name = nil, hostname = nil, opts = {})
        aname, hname, opts = Base.parse_new_params([app_name, hostname, opts])
        super(aname, hname, opts)
        init_opts_for_json(opts)
      end

      def _call(severity, time, progname, data)
        data.merge!({message: data.delete(:msg)})
        if data[:timestamp].present?
          time = data[:timestamp]
          data.delete(:timestamp)
        end
        dump({
          name: progname || @app_name,
          pid: $$,
          level: severity,
          timestamp: time.utc.strftime('%FT%T.%6NZ'),
        }.merge(data))
      end

      def convert_time(data)
        #data[:timestamp] = format_datetime(data[:time])
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
zuora_connect-2.0.60v lib/logging/connect_formatter.rb
zuora_connect-2.1.1 lib/logging/connect_formatter.rb
zuora_connect-2.0.60u lib/logging/connect_formatter.rb
zuora_connect-2.0.60t lib/logging/connect_formatter.rb
zuora_connect-2.0.60s lib/logging/connect_formatter.rb
zuora_connect-2.0.60r lib/logging/connect_formatter.rb
zuora_connect-2.0.60q lib/logging/connect_formatter.rb
zuora_connect-2.0.60p lib/logging/connect_formatter.rb
zuora_connect-2.0.60o lib/logging/connect_formatter.rb
zuora_connect-2.0.60n lib/logging/connect_formatter.rb
zuora_connect-2.0.60m lib/logging/connect_formatter.rb
zuora_connect-2.0.60l lib/logging/connect_formatter.rb
zuora_connect-2.0.60k lib/logging/connect_formatter.rb
zuora_connect-2.0.60j lib/logging/connect_formatter.rb
zuora_connect-2.0.60i lib/logging/connect_formatter.rb
zuora_connect-2.0.60h lib/logging/connect_formatter.rb
zuora_connect-2.0.60g lib/logging/connect_formatter.rb
zuora_connect-2.0.60f lib/logging/connect_formatter.rb
zuora_connect-2.0.60e lib/logging/connect_formatter.rb
zuora_connect-2.0.60d lib/logging/connect_formatter.rb