Class: Minato::Utils::BaseLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/minato/utils/logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ BaseLogger

Returns a new instance of BaseLogger.



20
21
22
23
24
# File 'lib/minato/utils/logger.rb', line 20

def initialize(logger)
  @logger = logger
  @logger.formatter = LogFormatter.new if @logger
  @debug = Minato::Utils.config.debug
end

Instance Method Details

#call(type, message) ⇒ Object



43
44
45
# File 'lib/minato/utils/logger.rb', line 43

def call(type, message)
  @logger.send type, message
end

#log_request(method, host, path, options) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/minato/utils/logger.rb', line 26

def log_request(method, host, path, options)
  return unless @logger

  call :info,
       message:      'Minato::Utils::Client starting request',
       http_request: request_data(method, host, path, options)
end

#log_response(method, host, path, options, response) ⇒ Object



34
35
36
37
38
39
40
41
# File 'lib/minato/utils/logger.rb', line 34

def log_response(method, host, path, options, response)
  return unless @logger

  call :info,
       message:       'Minato::Utils::Client receiving response',
       http_request:  request_data(method, host, path, options),
       http_response: response_data(response)
end