Class: Justlogging::Middleware

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

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



6
7
8
# File 'lib/justlogging/middleware.rb', line 6

def initialize(app, options = {})
  @app, @options = app, options
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/justlogging/middleware.rb', line 10

def call(env)
  Justlogging::Transaction.create(env['action_dispatch.request_id'], env)
  @app.call(env)
rescue Exception => exception
  unless includes_exception?(exception)
    Justlogging::Transaction.current.add_exception(
      Justlogging::ExceptionNotification.new(env, exception)
    )
  end
  raise exception
ensure
  Justlogging::Transaction.current.complete!
end