Class: Couchbase::Utils::GenericLoggerAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/couchbase/utils/generic_logger_adapter.rb

Constant Summary collapse

DATETIME_FORMAT =
"%Y-%m-%dT%H:%M:%S.%6N"

Instance Method Summary collapse

Constructor Details

#initialize(logger, verbose: false) ⇒ GenericLoggerAdapter

Returns a new instance of GenericLoggerAdapter.



25
26
27
28
# File 'lib/couchbase/utils/generic_logger_adapter.rb', line 25

def initialize(logger, verbose: false)
  @logger = logger
  @verbose = verbose
end

Instance Method Details

#log(level, thread_id, seconds, nanoseconds, payload, filename, line, function) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/couchbase/utils/generic_logger_adapter.rb', line 30

def log(level, thread_id, seconds, nanoseconds, payload, filename, line, function)
  return unless @logger.respond_to?(level)

  progname = "cxxcbc##{thread_id}"
  payload += " at #{filename}:#{line} #{function}" if @verbose && filename
  @logger.send(level,
               "[#{::Time.at(seconds, nanoseconds, :nanosecond).strftime(DATETIME_FORMAT)} #{progname}]  #{level} -- #{payload}")
end