Class: Fakturan::Logger
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- Fakturan::Logger
- Extended by:
- Forwardable
- Defined in:
- lib/fakturan_nu/middleware/logger.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ :bodies => false }
Instance Method Summary collapse
-
#call(env) ⇒ Object
ErrorStatuses = 400…600.
-
#initialize(app, logger = nil, options = {}) ⇒ Logger
constructor
A new instance of Logger.
- #on_complete(env) ⇒ Object
Constructor Details
#initialize(app, logger = nil, options = {}) ⇒ Logger
Returns a new instance of Logger.
9 10 11 12 13 14 15 16 |
# File 'lib/fakturan_nu/middleware/logger.rb', line 9 def initialize(app, logger = nil, = {}) super(app) @logger = logger || begin require 'logger' ::Logger.new(STDOUT) end @options = DEFAULT_OPTIONS.merge() end |
Instance Method Details
#call(env) ⇒ Object
ErrorStatuses = 400…600
22 23 24 25 26 27 28 29 |
# File 'lib/fakturan_nu/middleware/logger.rb', line 22 def call(env) if Fakturan.debug_log info "#{env.method} #{env.url.to_s}" debug('request') { dump_headers env.request_headers } debug('request') { dump_body(env[:body]) } if env[:body] && log_body?(:request) end super end |
#on_complete(env) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/fakturan_nu/middleware/logger.rb', line 31 def on_complete(env) if Fakturan.debug_log info('Status') { env.status.to_s } #debug('response') { dump_headers env.response_headers } debug('response') { dump_body env[:body] } if env[:body] && log_body?(:response) end end |