Class: Silencer::Rack::Logger

Inherits:
Rack::Logger
  • Object
show all
Includes:
Hush, Methods, Util
Defined in:
lib/silencer/rack/logger.rb

Constant Summary

Constants included from Methods

Methods::METHODS

Instance Method Summary collapse

Methods included from Util

extract_options!, wrap

Methods included from Methods

#define_routes

Constructor Details

#initialize(app, *args) ⇒ Logger

Returns a new instance of Logger.



15
16
17
18
19
20
21
22
23
# File 'lib/silencer/rack/logger.rb', line 15

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

  @enable_header = opts.delete(:enable_header) { true }

  super(app, *args)
end

Instance Method Details

#call(env) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/silencer/rack/logger.rb', line 25

def call(env)
  if silence_request?(env, enable_header: @enable_header)
    quiet(env) do
      super
    end
  else
    super
  end
end