Class: Faraday::Response::Logger
- Inherits:
-
Middleware
- Object
- Middleware
- Middleware
- Faraday::Response::Logger
- Extended by:
- Forwardable
- Defined in:
- lib/faraday/response/logger.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :bodies => false }
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, logger = nil, options = {}) ⇒ Logger
constructor
A new instance of Logger.
- #on_complete(env) ⇒ Object
Methods inherited from Middleware
dependency, inherited, loaded?, new
Methods included from MiddlewareRegistry
#fetch_middleware, #load_middleware, #lookup_middleware, #middleware_mutex, #register_middleware
Constructor Details
#initialize(app, logger = nil, options = {}) ⇒ Logger
Returns a new instance of Logger.
9 10 11 12 13 14 15 16 |
# File 'lib/faraday/response/logger.rb', line 9 def initialize(app, logger = nil, = {}) super(app) @logger = logger || begin require 'logger' ::Logger.new(STDOUT) end @options = DEFAULT_OPTIONS.merge() end |
Instance Method Details
#call(env) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/faraday/response/logger.rb', line 20 def call(env) info "#{env.method} #{env.url.to_s}" debug('request') { dump_headers env.request_headers } debug('request') { dump_body(env[:body]) } if env[:body] && log_body?(:request) super end |
#on_complete(env) ⇒ Object
27 28 29 30 31 |
# File 'lib/faraday/response/logger.rb', line 27 def on_complete(env) info('Status') { env.status.to_s } debug('response') { dump_headers env.response_headers } debug('response') { dump_body env[:body] } if env[:body] && log_body?(:response) end |