Sha256: 07a3d73b6a5a08e89b9b3aa941f34d06e666a08ef6bfeac5b64922bcd8c31654

Contents?: true

Size: 714 Bytes

Versions: 1

Compression:

Stored size: 714 Bytes

Contents

module Insque
  class JsonFormatter < ::Logger::Formatter
    def call(severity, time, progname, msg, additional_fields = {})
      message = case msg
                when ::String
                  { message: msg }
                when ::Hash
                  msg
                when ::Exception
                  {
                    error: "#{ msg.message } (#{ msg.class })",
                    error_class: "#{msg.class}",
                    backtrace: (msg.backtrace || []).join("\n\t")
                  }
                else
                  { message: msg.inspect }
                end
      "#{message.merge(timestamp: time, level: severity).merge(additional_fields).to_json}\n"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
insque-0.7.0 lib/insque/json_formatter.rb