Class: Trashed::Railtie::ExposeLoggerTagsToRackEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/trashed/railtie.rb

Overview

Middleware would like to emit tagged logs after Rails::Rack::Logger pops its tags. Introduce this haxware to stash the tags in the Rack env so we can reuse them later.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ExposeLoggerTagsToRackEnv

Returns a new instance of ExposeLoggerTagsToRackEnv.



13
14
15
# File 'lib/trashed/railtie.rb', line 13

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
# File 'lib/trashed/railtie.rb', line 17

def call(env)
  @app.call(env).tap do
    env['trashed.logger.tags'] = Array(Thread.current[:activesupport_tagged_logging_tags]).dup
  end
end