Class: RailsLogrageMiddleware::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_lograge_middleware/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



3
4
5
# File 'lib/rails_lograge_middleware/middleware.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/rails_lograge_middleware/middleware.rb', line 7

def call(env)
  begin
    response = @app.call(env)
  rescue Exception => ex
    log_exception(ex, env)
    raise
  end

  exception = env['action_dispatch.exception']
  log_exception(exception, env) if exception

  response
end