Sha256: b44c8817a12b0c9fe8403c75883778352ea09f1cbfac6fe80049800e2626c7c1

Contents?: true

Size: 977 Bytes

Versions: 6

Compression:

Stored size: 977 Bytes

Contents

module CrashLog
  # 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.

  class Rack
    def initialize(app)
      @app = app
      CrashLog.configuration.logger ||= Logger.new($stdout)
    end

    def call(env)
      begin
        response = @app.call(env)
      rescue Exception => exception
        CrashLog.notify(exception, :rack_env => env)
        raise
      end

      if env['rack.exception']
        CrashLog.notify(env['rack.exception'], :rack_env => env)
      end

      response
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
crashlog-1.0.3 lib/crash_log/rack.rb
crashlog-1.0.2.1 lib/crash_log/rack.rb
crashlog-1.0.2 lib/crash_log/rack.rb
crashlog-1.0.1 lib/crash_log/rack.rb
crashlog-1.0.0 lib/crash_log/rack.rb
crashlog-1.0.0.rc2 lib/crash_log/rack.rb