Sha256: 1e1d7029f4aae2ebe93ff8cafc3cb0a4db37b0ff62c411dea747e7a279df6c44

Contents?: true

Size: 759 Bytes

Versions: 13

Compression:

Stored size: 759 Bytes

Contents

require 'airbrake'
require 'faraday'



module Saddle
  module Middleware
    module Logging

      # Public: Reports exceptions to Airbrake
      #
      class AirbrakeLogger < Faraday::Middleware

        def initialize(app, airbrake_api_key=nil)
          super(app)
          @airbrake_api_key = airbrake_api_key
        end

        def call(env)
          begin
            @app.call(env)
          rescue => e
            # If we don't have an api key, use the default config
            if @airbrake_api_key
              ::Airbrake.notify(e, {:api_key => @airbrake_api_key} )
            else
              ::Airbrake.notify(e)
            end
            # Re-raise the error
            raise
          end
        end

      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
saddle-0.0.30 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.27 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.26 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.25 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.23 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.22 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.21 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.19 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.18 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.17 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.16 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.15 lib/saddle/middleware/logging/airbrake.rb
saddle-0.0.14 lib/saddle/middleware/logging/airbrake.rb