Module: Mongo::Loggable

Overview

Allows objects to easily log operations.

Since:

  • 2.0.0

Constant Summary collapse

PREFIX =

The standard MongoDB log prefix.

Since:

  • 2.0.0

'MONGODB'.freeze

Instance Method Summary collapse

Instance Method Details

#log_debug(message) ⇒ Object

Convenience method to log debug messages with the standard prefix.

Examples:

Log a debug message.

log_debug('Message')

Parameters:

  • message (String)

    The message to log.

Since:

  • 2.0.0



38
39
40
# File 'build/ruby-driver-master/lib/mongo/loggable.rb', line 38

def log_debug(message)
  logger.debug(format_message(message)) if logger.debug?
end

#log_error(message) ⇒ Object

Convenience method to log error messages with the standard prefix.

Examples:

Log a error message.

log_error('Message')

Parameters:

  • message (String)

    The message to log.

Since:

  • 2.0.0



50
51
52
# File 'build/ruby-driver-master/lib/mongo/loggable.rb', line 50

def log_error(message)
  logger.error(format_message(message)) if logger.error?
end

#log_fatal(message) ⇒ Object

Convenience method to log fatal messages with the standard prefix.

Examples:

Log a fatal message.

log_fatal('Message')

Parameters:

  • message (String)

    The message to log.

Since:

  • 2.0.0



62
63
64
# File 'build/ruby-driver-master/lib/mongo/loggable.rb', line 62

def log_fatal(message)
  logger.fatal(format_message(message)) if logger.fatal?
end

#log_info(message) ⇒ Object

Convenience method to log info messages with the standard prefix.

Examples:

Log a info message.

log_info('Message')

Parameters:

  • message (String)

    The message to log.

Since:

  • 2.0.0



74
75
76
# File 'build/ruby-driver-master/lib/mongo/loggable.rb', line 74

def log_info(message)
  logger.info(format_message(message)) if logger.info?
end

#log_warn(message) ⇒ Object

Convenience method to log warn messages with the standard prefix.

Examples:

Log a warn message.

log_warn('Message')

Parameters:

  • message (String)

    The message to log.

Since:

  • 2.0.0



86
87
88
# File 'build/ruby-driver-master/lib/mongo/loggable.rb', line 86

def log_warn(message)
  logger.warn(format_message(message)) if logger.warn?
end

#loggerLogger

Get the logger instance.

Examples:

Get the logger instance.

loggable.logger

Returns:

Since:

  • 2.1.0



98
99
100
# File 'build/ruby-driver-master/lib/mongo/loggable.rb', line 98

def logger
  ((options && options[:logger]) || Logger.logger)
end