Class: Couchbase::Utils::GenericLoggerAdapter
- Inherits:
-
Object
- Object
- Couchbase::Utils::GenericLoggerAdapter
- Defined in:
- lib/couchbase/utils/generic_logger_adapter.rb,
/Users/sergey.auseyau/code/couchbase-ruby-client/lib/couchbase/utils/generic_logger_adapter.rb more...
Constant Summary collapse
- DATETIME_FORMAT =
"%Y-%m-%dT%H:%M:%S.%6N".freeze
Instance Method Summary collapse
-
#initialize(logger, verbose: false) ⇒ GenericLoggerAdapter
constructor
A new instance of GenericLoggerAdapter.
- #log(level, thread_id, seconds, nanoseconds, payload, filename, line, function) ⇒ Object
Constructor Details
#initialize(logger, verbose: false) ⇒ GenericLoggerAdapter
Returns a new instance of GenericLoggerAdapter.
23 24 25 26 |
# File 'lib/couchbase/utils/generic_logger_adapter.rb', line 23 def initialize(logger, verbose: false) @logger = logger @verbose = verbose end |
Instance Method Details
#log(level, thread_id, seconds, nanoseconds, payload, filename, line, function) ⇒ Object
[View source]
28 29 30 31 32 33 34 35 |
# File 'lib/couchbase/utils/generic_logger_adapter.rb', line 28 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 |