mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Simplify TaggedLogging symbol shortcuts (thanks Jose!)
This commit is contained in:
parent
afde6fdd5e
commit
4a4927f753
1 changed files with 4 additions and 7 deletions
|
@ -1,9 +1,8 @@
|
||||||
module Rails
|
module Rails
|
||||||
module Rack
|
module Rack
|
||||||
# Enables easy tagging of any logging activity that occurs within the Rails request cycle. The tags are configured via the
|
# Enables easy tagging of any logging activity that occurs within the Rails request cycle. The tags are configured via the
|
||||||
# config.log_tags setting. The tags can either be strings, procs taking a request argument, or the symbols :uuid or :subdomain.
|
# config.log_tags setting. The tags can either be strings, procs taking a request argument, or symbols representing method
|
||||||
# The latter two are then automatically expanded to request.uuid and request.subdaomins.first -- the two most common tags
|
# names on request (so :uuid will result in request.uuid being added as a tag).
|
||||||
# desired in production logs.
|
|
||||||
class TaggedLogging
|
class TaggedLogging
|
||||||
def initialize(app, tags = nil)
|
def initialize(app, tags = nil)
|
||||||
@app, @tags = app, tags
|
@app, @tags = app, tags
|
||||||
|
@ -25,10 +24,8 @@ module Rails
|
||||||
case tag
|
case tag
|
||||||
when Proc
|
when Proc
|
||||||
tag.call(request)
|
tag.call(request)
|
||||||
when :uuid
|
when Symbol
|
||||||
request.uuid
|
request.send(tag)
|
||||||
when :subdomain
|
|
||||||
request.subdomains.first
|
|
||||||
else
|
else
|
||||||
tag
|
tag
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue