Class: Ashikawa::Core::MinimalLogger
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Ashikawa::Core::MinimalLogger
- Defined in:
- lib/ashikawa-core/minimal_logger.rb
Overview
A more minimal logger as replacement for the very chatty Faraday logger
Instance Attribute Summary collapse
-
#debug_headers ⇒ Boolean
readonly
Should HTTP headers be logged.
-
#logger ⇒ Logger
readonly
The logger to be used.
Instance Method Summary collapse
-
#call(env) ⇒ Object
Calls the this middleware and passes on to ‘super`.
-
#initialize(app, logger, options = {}) ⇒ MinimalLogger
constructor
Initialize the middleware.
-
#on_complete(env) ⇒ Object
The callback when the request was completed.
Constructor Details
#initialize(app, logger, options = {}) ⇒ MinimalLogger
Initialize the middleware
28 29 30 31 32 |
# File 'lib/ashikawa-core/minimal_logger.rb', line 28 def initialize(app, logger, = {}) super(app) @logger = logger @debug_headers = .fetch(:debug_headers) { false } end |
Instance Attribute Details
#debug_headers ⇒ Boolean (readonly)
Should HTTP headers be logged
20 21 22 |
# File 'lib/ashikawa-core/minimal_logger.rb', line 20 def debug_headers @debug_headers end |
#logger ⇒ Logger (readonly)
The logger to be used
14 15 16 |
# File 'lib/ashikawa-core/minimal_logger.rb', line 14 def logger @logger end |
Instance Method Details
#call(env) ⇒ Object
Calls the this middleware and passes on to ‘super`
38 39 40 41 |
# File 'lib/ashikawa-core/minimal_logger.rb', line 38 def call(env) logger.debug('request') { "#{env.method.upcase} #{env.url}#{dump_headers(env.request_headers)}" } super end |
#on_complete(env) ⇒ Object
The callback when the request was completed
47 48 49 |
# File 'lib/ashikawa-core/minimal_logger.rb', line 47 def on_complete(env) logger.debug('response') { "#{env.method.upcase} #{env.url} #{env.status}#{dump_headers(env.response_headers)}" } end |