Sha256: ee22c95eb5d1500a244ce61420edd0adb75d3af552b37efd3dc27ac326da6b64

Contents?: true

Size: 874 Bytes

Versions: 13

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'
require 'logger'
require 'faraday/logging/formatter'

module Faraday
  class Response
    # Logger is a middleware that logs internal events in the HTTP request
    # lifecycle to a given Logger object. By default, this logs to STDOUT. See
    # Faraday::Logging::Formatter to see specifically what is logged.
    class Logger < Middleware
      def initialize(app, logger = nil, options = {})
        super(app)
        logger ||= ::Logger.new($stdout)
        formatter_class = options.delete(:formatter) || Logging::Formatter
        @formatter = formatter_class.new(logger: logger, options: options)
        yield @formatter if block_given?
      end

      def call(env)
        @formatter.request(env)
        super
      end

      def on_complete(env)
        @formatter.response(env)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 6 rubygems

Version Path
avalara_sdk-24.12.2 vendor/bundle/ruby/2.7.0/gems/faraday-1.10.4/lib/faraday/response/logger.rb
avalara_sdk-24.12.1 vendor/bundle/ruby/2.7.0/gems/faraday-1.10.4/lib/faraday/response/logger.rb
avalara_sdk-24.12.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.10.4/lib/faraday/response/logger.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/faraday-1.10.3/lib/faraday/response/logger.rb
faraday-1.10.4 lib/faraday/response/logger.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/faraday-1.10.3/lib/faraday/response/logger.rb
faraday-1.10.3 lib/faraday/response/logger.rb
faraday-1.10.2 lib/faraday/response/logger.rb
faraday-1.10.1 lib/faraday/response/logger.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/faraday-1.10.0/lib/faraday/response/logger.rb
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/response/logger.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/faraday-1.10.0/lib/faraday/response/logger.rb
faraday-1.10.0 lib/faraday/response/logger.rb