Class: Rails::Rack::Logger

Inherits:
ActiveSupport::LogSubscriber show all
Defined in:
railties/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.

Constant Summary

Constants inherited from ActiveSupport::LogSubscriber

ActiveSupport::LogSubscriber::BLACK, ActiveSupport::LogSubscriber::BLUE, ActiveSupport::LogSubscriber::BOLD, ActiveSupport::LogSubscriber::CLEAR, ActiveSupport::LogSubscriber::CYAN, ActiveSupport::LogSubscriber::GREEN, ActiveSupport::LogSubscriber::MAGENTA, ActiveSupport::LogSubscriber::RED, ActiveSupport::LogSubscriber::WHITE, ActiveSupport::LogSubscriber::YELLOW

Instance Attribute Summary

Attributes inherited from ActiveSupport::Subscriber

#patterns

Instance Method Summary collapse

Methods inherited from ActiveSupport::LogSubscriber

flush_all!, log_subscribers, #start

Methods inherited from ActiveSupport::Subscriber

attach_to, detach_from, method_added, #start, subscribers

Constructor Details

#initialize(app, taggers = nil) ⇒ Logger

Returns a new instance of Logger.



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

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

Instance Method Details

#call(env) ⇒ Object



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

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