Class: Couchbase::Utils::StdlibLoggerAdapter
- Inherits:
-
Object
- Object
- Couchbase::Utils::StdlibLoggerAdapter
- Defined in:
- lib/couchbase/utils/stdlib_logger_adapter.rb,
/code/couchbase-ruby-client/lib/couchbase/utils/stdlib_logger_adapter.rb
Instance Method Summary collapse
-
#initialize(logger, verbose: false) ⇒ StdlibLoggerAdapter
constructor
A new instance of StdlibLoggerAdapter.
- #log(level, thread_id, seconds, nanoseconds, payload, filename, line, function) ⇒ Object
Constructor Details
#initialize(logger, verbose: false) ⇒ StdlibLoggerAdapter
Returns a new instance of StdlibLoggerAdapter.
24 25 26 27 28 29 |
# File 'lib/couchbase/utils/stdlib_logger_adapter.rb', line 24 def initialize(logger, verbose: false) raise ArgumentError, "logger argument must be or derive from stdlib Logger class" unless logger.is_a?(::Logger) @logger = logger @verbose = verbose end |
Instance Method Details
#log(level, thread_id, seconds, nanoseconds, payload, filename, line, function) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/couchbase/utils/stdlib_logger_adapter.rb', line 31 def log(level, thread_id, seconds, nanoseconds, payload, filename, line, function) logdev = @logger.instance_variable_get(:@logdev) return unless logdev severity = map_spdlog_level(level) return unless severity progname = "cxxcbc##{thread_id}" payload += " at #{filename}:#{line} #{function}" if @verbose && filename logdev.write( @logger.send(:format_message, @logger.send(:format_severity, severity), ::Time.at(seconds, nanoseconds, :nanosecond), progname, payload) ) end |