123456789_123456789_123456789_123456789_123456789_

Class: Mongo::Logger

Relationships & Source Files
Inherits: Object
Defined in: lib/mongo/logger.rb

Overview

Provides ability to log messages.

Since:

  • 2.0.0

Class Attribute Summary

Class Method Summary

Class Attribute Details

.levelInteger (rw)

Get the global logger level.

Examples:

Get the global logging level.

Mongo::Logger.level

Returns:

  • (Integer)

    The log level.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/logger.rb', line 62

def level
  logger.level
end

.level=(level) ⇒ Integer (rw)

Set the global logger level.

Examples:

Set the global logging level.

Mongo::Logger.level == Logger::DEBUG

Returns:

  • (Integer)

    The log level.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/logger.rb', line 74

def level=(level)
  logger.level = level
end

.logger::Logger (rw)

Get the wrapped logger. If none was set will return a default info level logger.

Examples:

Get the wrapped logger.

Mongo::Logger.logger

Returns:

  • (::Logger)

    The wrapped logger.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/logger.rb', line 36

def logger
  @logger ||= default_logger
end

.logger=(other) ⇒ ::Logger (rw)

Set the logger.

Examples:

Set the wrapped logger.

Mongo::Logger.logger = logger

Parameters:

  • other (::Logger)

    The logger to set.

Returns:

  • (::Logger)

    The wrapped logger.

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/logger.rb', line 50

def logger=(other)
  @logger = other
end

Class Method Details

.default_logger (private)

Since:

  • 2.0.0

[ GitHub ]

  
# File 'lib/mongo/logger.rb', line 80

def default_logger
  logger = ::Logger.new(STDOUT)
  logger.level = ::Logger::INFO
  logger
end