Class: Ably::Rest::Middleware::Logger
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Ably::Rest::Middleware::Logger
- Extended by:
- Forwardable
- Defined in:
- lib/ably/rest/middleware/logger.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, logger = nil) ⇒ Logger
constructor
A new instance of Logger.
- #on_complete(env) ⇒ Object
Constructor Details
#initialize(app, logger = nil) ⇒ Logger
Returns a new instance of Logger.
9 10 11 12 13 14 15 |
# File 'lib/ably/rest/middleware/logger.rb', line 9 def initialize(app, logger = nil) super(app) @logger = logger || begin require 'logger' ::Logger.new(STDOUT) end end |
Instance Method Details
#call(env) ⇒ Object
19 20 21 22 23 |
# File 'lib/ably/rest/middleware/logger.rb', line 19 def call(env) debug { "=> URL: #{env.method} #{env.url}, Headers: #{dump_headers env.request_headers}" } debug { "=> Body: #{body_for(env)}" } super end |
#on_complete(env) ⇒ Object
25 26 27 28 |
# File 'lib/ably/rest/middleware/logger.rb', line 25 def on_complete(env) debug "<= Status: #{env.status}, Headers: #{dump_headers env.response_headers}" debug "<= Body: #{body_for(env)}" end |