Class: Silencer::Rails::Logger

Inherits:
Rails::Rack::Logger
  • Object
show all
Includes:
Hush, Methods, Util
Defined in:
lib/silencer/rails/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.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/silencer/rails/logger.rb', line 16

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 }

  normalized_args = normalize(args)
  if normalized_args
    super(app, normalized_args)
  else
    super(app)
  end
end

Instance Method Details

#call(env) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/silencer/rails/logger.rb', line 31

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