Class: Rack::Loggr

Inherits:
Object
  • Object
show all
Defined in:
lib/loggr-rb/integration/rack.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, api_key = nil) ⇒ Loggr

Returns a new instance of Loggr.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/loggr-rb/integration/rack.rb', line 7

def initialize(app, api_key = nil)
  @app = app
  if api_key.nil?
    loggr_config = "config/loggr.yml"
    ::Loggr::Config.load(loggr_config)
  else
    ::Loggr.configure(api_key)
    ::Loggr::Config.enabled = true
    ::Loggr.logger.info "Enabling Loggr for Rack"
  end
end

Instance Method Details

#call(env) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/loggr-rb/integration/rack.rb', line 19

def call(env)
  begin
    status, headers, body =  @app.call(env)
  rescue Exception => e
    ::Loggr::Catcher.handle_with_rack(e,env, Rack::Request.new(env))
    raise(e)
  end
end