Class: GoogleCloudRun::LoggerMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/google_cloud_run/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ LoggerMiddleware

Returns a new instance of LoggerMiddleware.



287
288
289
# File 'lib/google_cloud_run/logger.rb', line 287

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

A middleware which injects the request into the Rails.logger



292
293
294
295
296
297
298
# File 'lib/google_cloud_run/logger.rb', line 292

def call(env)
  request = ActionDispatch::Request.new(env)
  Rails.logger.inject_request(request)
  @app.call(env)
ensure
  ActiveSupport::LogSubscriber.flush_all!
end