Class: Faraday::Response::Logger

Inherits:
Middleware show all
Extended by:
Forwardable
Defined in:
lib/faraday/response/logger.rb

Instance Method Summary collapse

Methods inherited from Middleware

adapter?, dependency, inherited, loaded?, new

Methods included from MiddlewareRegistry

#lookup_middleware, #register_middleware

Constructor Details

#initialize(app, logger = nil) ⇒ Logger

Returns a new instance of Logger.



7
8
9
10
11
12
13
# File 'lib/faraday/response/logger.rb', line 7

def initialize(app, logger = nil)
  super(app)
  @logger = logger || begin
    require 'logger'
    ::Logger.new(STDOUT)
  end
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
# File 'lib/faraday/response/logger.rb', line 17

def call(env)
  info "#{env[:method]} #{env[:url].to_s}"
  debug('request') { dump_headers env[:request_headers] }
  super
end

#on_complete(env) ⇒ Object



23
24
25
26
# File 'lib/faraday/response/logger.rb', line 23

def on_complete(env)
  info('Status') { env[:status].to_s }
  debug('response') { dump_headers env[:response_headers] }
end