Class: TaggedLogger
- Inherits:
-
Object
- Object
- TaggedLogger
- Defined in:
- lib/sensible_logging/middlewares/tagged_logger.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #default_tags ⇒ Object
-
#initialize(app, logger = Logger.new(STDOUT), tags = [], tld_length = 1) ⇒ TaggedLogger
constructor
A new instance of TaggedLogger.
Constructor Details
#initialize(app, logger = Logger.new(STDOUT), tags = [], tld_length = 1) ⇒ TaggedLogger
4 5 6 7 8 9 10 11 12 |
# File 'lib/sensible_logging/middlewares/tagged_logger.rb', line 4 def initialize(app, logger = Logger.new(STDOUT), = [], tld_length = 1) @app = app @logger = ActiveSupport::TaggedLogging.new(logger) = = if .empty? @tld_length = tld_length end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/sensible_logging/middlewares/tagged_logger.rb', line 14 def call(env) @logger.tagged(*(env)) do |logger| env['logger'] = logger @app.call(env) end end |
#default_tags ⇒ Object
21 22 23 24 25 |
# File 'lib/sensible_logging/middlewares/tagged_logger.rb', line 21 def [lambda { |req| [subdomain(req), ENV['RACK_ENV'], req.env['request_id']] }] end |