class LogJam::Logger

This class represents a specialization of the Ruby Logger class. The class retains a Ruby Logger instance within itself and delegates all standard logger calls to this instance. This allows for changes to the underlying logger without changing the containing one, thus bypassing people caching an instance.

Attributes

name[RW]

Attribute accessor/mutator declaration.

Public Class Methods

new(logdev, shift_age=0, shift_size=1048576) click to toggle source

Constructor for the Logger class. All parameters are passed straight through to create a standard Ruby Logger instance except when the first parameter is a Logger instance. In this case the Logger passed in is used rather than creating a new one.

Parameters

logdev

The log device to be used by the logger. This should be be a String containing a file path/name, an IO object that the logging details will be written to or another logger that you want to wrap.

shift_age

The maximum number of old log files to retain or a String containing the rotation frequency for the log.

shift_size

The maximum size that the logging output will be allowed to grow to before rotation occurs.

# File lib/logjam/logger.rb, line 34
def initialize(logdev, shift_age=0, shift_size=1048576)
  @log = (logdev.kind_of?(::Logger) ? logdev : ::Logger.new(logdev, shift_age, shift_size))
  @name = nil
end

Public Instance Methods

logger() click to toggle source

This method fetches the standard Ruby Logger instance contained within a Logger object.

# File lib/logjam/logger.rb, line 44
def logger
  @log
end
logger=(logger) click to toggle source

This method updates the logger instance contained within a Logger object.

Parameters

logger

The object to set as the contained logger. This should be an instance of the standard Ruby Logger class or something compatible with this.

# File lib/logjam/logger.rb, line 55
def logger=(logger)
  @log = logger
end