Class: TaggedLogger
- Inherits:
-
Object
- Object
- TaggedLogger
- Defined in:
- lib/sensible_logging/middlewares/tagged_logger.rb
Overview
Allow custom tags to be captured
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, logger: Logger.new(STDOUT), tags: [], use_default_tags: true, tld_length: 1, include_log_severity: true) ⇒ TaggedLogger
constructor
rubocop:disable Metrics/ParameterLists.
Constructor Details
#initialize(app, logger: Logger.new(STDOUT), tags: [], use_default_tags: true, tld_length: 1, include_log_severity: true) ⇒ TaggedLogger
rubocop:disable Metrics/ParameterLists
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/sensible_logging/middlewares/tagged_logger.rb', line 9 def initialize( # rubocop:disable Metrics/ParameterLists app, logger: Logger.new(STDOUT), tags: [], use_default_tags: true, tld_length: 1, include_log_severity: true ) @app = app logger = setup_severity_tag(logger) if include_log_severity @logger = ActiveSupport::TaggedLogging.new(logger) = [] += (tld_length: tld_length) if += end |
Instance Method Details
#call(env) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/sensible_logging/middlewares/tagged_logger.rb', line 27 def call(env) @logger.tagged(*(env)) do |logger| env['logger'] = logger @app.call(env) end end |