Class: Vonage::Logger
- Inherits:
-
Object
- Object
- Vonage::Logger
- Extended by:
- Forwardable, T::Sig
- Defined in:
- lib/vonage/logger.rb
Instance Method Summary collapse
-
#initialize(logger) ⇒ Logger
constructor
A new instance of Logger.
- #log_request_info(request) ⇒ Object
- #log_response_info(response, host) ⇒ Object
Constructor Details
#initialize(logger) ⇒ Logger
Returns a new instance of Logger.
15 16 17 |
# File 'lib/vonage/logger.rb', line 15 def initialize(logger) @logger = logger || ::Logger.new(nil) end |
Instance Method Details
#log_request_info(request) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/vonage/logger.rb', line 26 def log_request_info(request) T.must(@logger).info do format('Vonage API request', { method: request.method, path: request.uri.path }) end end |
#log_response_info(response, host) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/vonage/logger.rb', line 39 def log_response_info(response, host) T.must(@logger).info do format('Vonage API response', { host: host, status: response.code, type: response.content_type, length: response.content_length, trace_id: response['x-Vonage-trace-id'] }) end end |