Class: Rails::Rack::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/lograge/rails_ext/rack/logger.rb

Overview

Overwrites defaults of Rails::Rack::Logger that cause unnecessary logging. This effectively removes the log lines from the log that say: Started GET / for 192.168.2.1…

Instance Method Summary collapse

Instance Method Details

#before_dispatch(_env) ⇒ Object

Overwrites Rails 3.0/3.1 code that logs new requests



27
# File 'lib/lograge/rails_ext/rack/logger.rb', line 27

def before_dispatch(_env); end

#call_app(*args) ⇒ Object

Overwrites Rails code that logs new requests



16
17
18
19
20
21
22
23
24
# File 'lib/lograge/rails_ext/rack/logger.rb', line 16

def call_app(*args)
  env = args.last
  status, headers, body = @app.call(env)
  # needs to have same return type as the Rails builtins being overridden, see https://github.com/roidrage/lograge/pull/333
  # https://github.com/rails/rails/blob/be9d34b9bcb448b265114ebc28bef1a5b5e4c272/railties/lib/rails/rack/logger.rb#L37
  [status, headers, ::Rack::BodyProxy.new(body) {}] # rubocop:disable Lint/EmptyBlock
ensure
  ActiveSupport::LogSubscriber.flush_all!
end