Class: CrashLog::Rack
- Inherits:
-
Object
- Object
- CrashLog::Rack
- Defined in:
- lib/crash_log/rack.rb
Overview
CrashLog Middleware for Rack applications. Any errors raised by the upstream application will be delivered to CrashLog and re-raised.
Synopsis:
require 'rack'
require 'crashlog'
CrashLog.configure do |config|
config.api_key = 'project-api-key'
end
app = Rack::Builder.app do
run lambda { |env| raise "Fully Racked" }
end
use CrashLog::Rack
run app
Use a standard CrashLog.configure call to configure your api key.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Rack
constructor
A new instance of Rack.
Constructor Details
#initialize(app) ⇒ Rack
Returns a new instance of Rack.
24 25 26 27 |
# File 'lib/crash_log/rack.rb', line 24 def initialize(app) @app = app CrashLog.configuration.logger ||= Logger.new($stdout) end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/crash_log/rack.rb', line 29 def call(env) begin response = @app.call(env) rescue Exception => exception CrashLog.notify_or_ignore(exception, :rack_env => env) raise end if env['rack.exception'] CrashLog.notify_or_ignore(env['rack.exception'], :rack_env => env) end response end |