Class: FaradayMiddleware::LoudLogger
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- FaradayMiddleware::LoudLogger
- Extended by:
- Forwardable
- Defined in:
- lib/faraday/loud_logger.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ LoudLogger
constructor
A new instance of LoudLogger.
Constructor Details
#initialize(app, options = {}) ⇒ LoudLogger
Returns a new instance of LoudLogger.
10 11 12 13 14 15 16 |
# File 'lib/faraday/loud_logger.rb', line 10 def initialize(app, = {}) @app = app @logger = .fetch(:logger) { require 'logger' ::Logger.new($stdout) } end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/faraday/loud_logger.rb', line 18 def call(env) start_time = Time.now info { 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 |