Sha256: 3631eac67ed9ae2b511bbefcc97c88f20c5c8f76f672bf7000523dd0cda50047

Contents?: true

Size: 509 Bytes

Versions: 50

Compression:

Stored size: 509 Bytes

Contents

require 'logger'
class Rack::App::Logger < ::Logger
  attr_writer :id

  def initialize(*args)
    super
    configure!
  end

  protected

  def id
    @id ||= SecureRandom.hex
  end

  def configure!
    original_formatter = Logger::Formatter.new
    self.formatter = proc do |severity, datetime, progname, msg|
      fmsg = msg.is_a?(::Hash) ? (defined?(::JSON) ? JSON.dump(msg) : msg) : msg
      fprname = progname || id
      original_formatter.call(severity, datetime, fprname, fmsg)
    end
  end
end

Version data entries

50 entries across 50 versions & 2 rubygems

Version Path
rack-app-11.0.2 lib/rack/app/logger.rb
rack-app-11.0.1 lib/rack/app/logger.rb
rack-app-11.0.0 lib/rack/app/logger.rb
rack-app-10.0.0 lib/rack/app/logger.rb
rack-app-9.0.0 lib/rack/app/logger.rb
rack-app-8.1.0 lib/rack/app/logger.rb
rack-app-8.0.1 lib/rack/app/logger.rb
rack-app-8.0.0 lib/rack/app/logger.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/rack-app-7.7.0/lib/rack/app/logger.rb
rack-app-7.7.0 lib/rack/app/logger.rb
rack-app-7.6.5 lib/rack/app/logger.rb
rack-app-7.6.4 lib/rack/app/logger.rb
rack-app-7.6.3 lib/rack/app/logger.rb
rack-app-7.6.2 lib/rack/app/logger.rb
rack-app-7.6.1 lib/rack/app/logger.rb
rack-app-7.6.0 lib/rack/app/logger.rb
rack-app-7.5.2 lib/rack/app/logger.rb
rack-app-7.5.1 lib/rack/app/logger.rb
rack-app-7.5.0 lib/rack/app/logger.rb
rack-app-7.4.0 lib/rack/app/logger.rb