Class Needle::LogFactory
In: lib/needle/log-factory.rb
Parent: Object

A factory class that returns Logger instances. Since each registry has its own logger factory, the logger factory must be separately instantiable.

Methods

close   closed?   get   new   write_to  

Constants

DEFAULT_LOG_FILENAME = "./needle.log"   The default name of the log file to write to.
DEFAULT_MESSAGE_FORMAT = "[%-5p] %d -- %C: %m"   The default format of the log messages (see Logger for more info)
LEVEL_TRANSLATOR = { "DEBUG" => Logger::DEBUG, "INFO" => Logger::INFO, "WARN" => Logger::WARN, "ERROR" => Logger::ERROR, "FATAL" => Logger::FATAL, "UNKNOWN" => Logger::UNKNOWN   Translate names of levels to their actual values.
VALID_OPTIONS = [ :device, :filename, :roll_age, :roll_frequency, :roll_size, :default_date_format, :default_message_format, :default_level, :levels ]
VALID_LEVEL_OPTIONS = [ :level, :date_format, :message_format ]

Attributes

default_date_format  [R]  The default date format string to use when logging.
default_level  [R]  The default log level to use for logs that are created.
default_message_format  [R]  The default message format string to use when logging.
device  [R]  The device that logs will write to.

Public Class methods

Create a new LogFactory using the given initialization parameters. The valid options are:

  • :device: the device (pseudo-IO object) to write log messages to. Either this, or :filename must be specified.
  • :filename: the filename of the log to write to.
  • :roll_age: the number of days before the log should be rolled.
  • :roll_frequency: either ‘daily’, ‘weekly’, or ‘monthly’.
  • :roll_size: the maximum size of a log file.
  • :default_date_format: the default date format string for the log.
  • :default_message_format: the default message format string for the log.
  • :default_level: the default log level for the log.
  • :levels: a hash of patterns that map to a hash of ‘level’ ‘date_format’, and ‘message_format’ keys, specifying the log level, date format, and message format for any log whose name matches the key.

Public Instance methods

Closes the logging device and makes this factory invalid for future accesses.

Returns true if the factory has been closed.

Retrieves the logger with the given name. If no such log has been created, the log will be created and initialized. Otherwise, the log with the given name is returned.

If name responds to either fullname or name, then the result of invoking that message on name will be used as the name.

Changes the device that the loggers write to. Every log that was created by this log factory will be changed to use the given device.

[Validate]