Class: HTTPigeon::Middleware::HTTPigeonLogger
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- HTTPigeon::Middleware::HTTPigeonLogger
- Defined in:
- lib/httpigeon/middleware/httpigeon_logger.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, logger) ⇒ HTTPigeonLogger
constructor
A new instance of HTTPigeonLogger.
- #on_complete(env) ⇒ Object
Constructor Details
#initialize(app, logger) ⇒ HTTPigeonLogger
Returns a new instance of HTTPigeonLogger.
8 9 10 11 12 |
# File 'lib/httpigeon/middleware/httpigeon_logger.rb', line 8 def initialize(app, logger) super(app) @logger = logger end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/httpigeon/middleware/httpigeon_logger.rb', line 14 def call(env) logger.on_request_start if logger.respond_to?(:on_request_start) super rescue StandardError => e logger.on_request_finish if logger.respond_to?(:on_request_finish) logger.log(env, { error: e }) raise e end |
#on_complete(env) ⇒ Object
25 26 27 28 |
# File 'lib/httpigeon/middleware/httpigeon_logger.rb', line 25 def on_complete(env) logger.on_request_finish if logger.respond_to?(:on_request_finish) logger.log(env) end |