Sha256: 8ba4b260aa4d8b5d0b6acf678813d775f5c54d9837b387cb08b56f26a2c4ac4d

Contents?: true

Size: 591 Bytes

Versions: 1

Compression:

Stored size: 591 Bytes

Contents

require 'rack/logger'
require 'silencer/util'
require 'silencer/hush'

module Silencer
  module Rack
    class Logger < ::Rack::Logger
      include Silencer::Util
      include Silencer::Hush

      def initialize(app, *args)
        opts     = extract_options!(args)
        @silence = wrap(opts.delete(:silence))

        super app, *args
      end

      def call(env)
        logger       = ::Logger.new(env['rack.errors'])
        logger.level = (silence_request?(env) ? ::Logger::ERROR : @level)

        env['rack.logger'] = logger
        @app.call(env)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
silencer-1.0.0.rc1 lib/silencer/rack/logger.rb