Sha256: a549128272b5eeb9f3982b36f1286ad5e41c567eee461643a3763c58353ff201

Contents?: true

Size: 912 Bytes

Versions: 74

Compression:

Stored size: 912 Bytes

Contents

# frozen_string_literal: true

require 'forwardable'
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 ||= begin
          require 'logger'
          ::Logger.new($stdout)
        end
        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

74 entries across 61 versions & 13 rubygems

Version Path
mx-platform-ruby-0.3.2 vendor/bundle/ruby/2.6.0/gems/faraday-1.7.0/lib/faraday/response/logger.rb
mx-platform-ruby-0.3.1 vendor/bundle/ruby/2.6.0/gems/faraday-1.7.0/lib/faraday/response/logger.rb
faraday-1.7.0 lib/faraday/response/logger.rb
faraday-1.6.0 lib/faraday/response/logger.rb
faraday-1.5.1 lib/faraday/response/logger.rb
faraday-1.5.0 lib/faraday/response/logger.rb
faraday-1.4.3 lib/faraday/response/logger.rb
passbase-1.3.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.4.2/lib/faraday/response/logger.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/faraday-1.4.2/lib/faraday/response/logger.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/faraday-1.4.2/lib/faraday/response/logger.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/vendor/bundle/ruby/2.7.0/gems/faraday-1.1.0/lib/faraday/response/logger.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/faraday-1.2.0/lib/faraday/response/logger.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/faraday-1.1.0/lib/faraday/response/logger.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/faraday-1.3.0/lib/faraday/response/logger.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/faraday-1.3.0/lib/faraday/response/logger.rb
faraday-1.4.2 lib/faraday/response/logger.rb
cocRb-0.1.0 .bundle/ruby/3.0.0/gems/faraday-1.4.1/lib/faraday/response/logger.rb
faraday-1.4.1 lib/faraday/response/logger.rb
faraday-1.4.0 lib/faraday/response/logger.rb
faraday-1.3.1 lib/faraday/response/logger.rb