Class: Vonage::Logger

Inherits:
Object
  • Object
show all
Extended by:
Forwardable, T::Sig
Defined in:
lib/vonage/logger.rb

Instance Method Summary collapse

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