1
0
Fork 0
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:
David Heinemeier Hansson 2011-10-19 13:24:28 -05:00
parent afde6fdd5e
commit 4a4927f753

View file

@ -1,9 +1,8 @@
module Rails
module Rack
# 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.
# The latter two are then automatically expanded to request.uuid and request.subdaomins.first -- the two most common tags
# desired in production logs.
# config.log_tags setting. The tags can either be strings, procs taking a request argument, or symbols representing method
# names on request (so :uuid will result in request.uuid being added as a tag).
class TaggedLogging
def initialize(app, tags = nil)
@app, @tags = app, tags
@ -25,10 +24,8 @@ module Rails
case tag
when Proc
tag.call(request)
when :uuid
request.uuid
when :subdomain
request.subdomains.first
when Symbol
request.send(tag)
else
tag
end