1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

More docs on tagged logging [ci skip]

Mention that tags can also come from a Proc that accepts the request
object or something's to_s method
This commit is contained in:
sshaw 2015-03-06 22:15:36 -05:00
parent 387e7be458
commit f9369c0f51
2 changed files with 4 additions and 1 deletions

View file

@ -114,7 +114,7 @@ numbers. New applications filter out passwords by adding the following `config.f
defaults to `:debug` for all environments. The available log levels are: `:debug`, defaults to `:debug` for all environments. The available log levels are: `:debug`,
`:info`, `:warn`, `:error`, `:fatal`, and `:unknown`. `:info`, `:warn`, `:error`, `:fatal`, and `:unknown`.
* `config.log_tags` accepts a list of methods that the `request` object responds to. This makes it easy to tag log lines with debug information like subdomain and request id - both very helpful in debugging multi-user production applications. * `config.log_tags` accepts a list of: methods that the `request` object responds to, a `Proc` that accepts the `request` object, or something that responds to `to_s`. This makes it easy to tag log lines with debug information like subdomain and request id - both very helpful in debugging multi-user production applications.
* `config.logger` accepts a logger conforming to the interface of Log4r or the default Ruby `Logger` class. Defaults to an instance of `ActiveSupport::Logger`. * `config.logger` accepts a logger conforming to the interface of Log4r or the default Ruby `Logger` class. Defaults to an instance of `ActiveSupport::Logger`.

View file

@ -7,6 +7,9 @@ require 'rack/body_proxy'
module Rails module Rails
module Rack module Rack
# Sets log tags, logs the request, calls the app, and flushes the logs. # Sets log tags, logs the request, calls the app, and flushes the logs.
#
# Log tags can be an Array containing: methods that the <tt>request</tt> object responds to, a Proc
# that accepts an instance of the <tt>request</tt> object, or something that responds to <tt>to_s</tt>.
class Logger < ActiveSupport::LogSubscriber class Logger < ActiveSupport::LogSubscriber
def initialize(app, taggers = nil) def initialize(app, taggers = nil)
@app = app @app = app