Class: Faraday::Conductivity::ExtendedLogging

Inherits:
Middleware
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/faraday/conductivity/extended_logging.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ ExtendedLogging

Returns a new instance of ExtendedLogging.



10
11
12
13
14
15
16
# File 'lib/faraday/conductivity/extended_logging.rb', line 10

def initialize(app, options = {})
  @app = app
  @logger = options.fetch(:logger) {
    require 'logger'
    ::Logger.new($stderr)
  }
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/faraday/conductivity/extended_logging.rb', line 18

def call(env)
  start_time = Time.now
  debug { request_info(env) }
  debug { request_debug(env) }
  @app.call(env).on_complete do
    end_time = Time.now
    response_time = end_time - start_time
    info  { response_info(env, response_time) }
    debug { response_debug(env) }
  end
end