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

dependency, loaded?, setup_parallel_manager

Constructor Details

- (Logger) initialize(app, logger = nil)

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

- (Object) call(env)



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

- (Object) on_complete(env)



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