Sha256: 1ff739b64a4b624c4a7ddd700d5bcdea7f755c2123076bc72a0fae8eaa96c55b

Contents?: true

Size: 519 Bytes

Versions: 1

Compression:

Stored size: 519 Bytes

Contents

require 'faraday'



module Saddle
  module Middleware
    module Logging

      # Public: Log exceptions using the Rails logger
      #
      class RailsLogger < Faraday::Middleware

        def call(env)
          begin
            @app.call(env)
          rescue => e
            if defined?(Rails.logger)
              Rails.logger.error("#{env[:request][:saddle][:client].name} error: #{e}")
            end
            # Re-raise the error
            raise
          end
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
saddle-0.0.53 lib/saddle/middleware/logging/rails.rb