Class: Rails::Rack::Logger
- Inherits:
-
ActiveSupport::LogSubscriber
- Object
- ActiveSupport::Subscriber
- ActiveSupport::LogSubscriber
- Rails::Rack::Logger
- 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::CYAN, ActiveSupport::LogSubscriber::GREEN, ActiveSupport::LogSubscriber::LEVEL_CHECKS, ActiveSupport::LogSubscriber::MAGENTA, ActiveSupport::LogSubscriber::MODES, ActiveSupport::LogSubscriber::RED, ActiveSupport::LogSubscriber::WHITE, ActiveSupport::LogSubscriber::YELLOW
Instance Attribute Summary
Attributes inherited from ActiveSupport::LogSubscriber
Attributes inherited from ActiveSupport::Subscriber
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, taggers = nil) ⇒ Logger
constructor
A new instance of Logger.
Methods inherited from ActiveSupport::LogSubscriber
attach_to, flush_all!, log_subscribers, #publish_event, #silenced?
Methods inherited from ActiveSupport::Subscriber
attach_to, detach_from, method_added, #publish_event, subscribers
Constructor Details
#initialize(app, taggers = nil) ⇒ Logger
Returns a new instance of Logger.
15 16 17 18 |
# File 'railties/lib/rails/rack/logger.rb', line 15 def initialize(app, taggers = nil) @app = app @taggers = taggers || [] end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'railties/lib/rails/rack/logger.rb', line 20 def call(env) request = ActionDispatch::Request.new(env) env["rails.rack_logger_tag_count"] = if logger.respond_to?(:push_tags) logger.(*(request)).size else 0 end call_app(request, env) end |