Class: Rails::Rack::Logger

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/rails/rack/logger.rb

Overview

Sets log tags, logs the request, calls the app, and flushes the logs.

Log tags (taggers) can be an Array containing: methods that the request object responds to, objects that respond to to_s or Proc objects that accept an instance of the request object.

Instance Method Summary collapse

Constructor Details

#initialize(app, taggers = nil) ⇒ Logger

Returns a new instance of Logger.



16
17
18
19
# File 'lib/rails/rack/logger.rb', line 16

def initialize(app, taggers = nil)
  @app          = app
  @taggers      = taggers || []
end

Instance Method Details

#call(env) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/rails/rack/logger.rb', line 21

def call(env)
  request = ActionDispatch::Request.new(env)

  if logger.respond_to?(:tagged)
    logger.tagged(compute_tags(request)) { call_app(request, env) }
  else
    call_app(request, env)
  end
end