Class | Eymiha::EasyLogger |
In: |
lib/eymiha/util/easylog.rb
|
Parent: | Logger |
Primarily, EasyLogger provides a convienient interface to the Logger at the class level. The class contains a "default" instance of Logger to which the class methods send their log messages. By convention, the first instance created is made the default, however this can be changed. Of course, instances may be used directly for logging if desired. Instances format their log entries using an EasyLogFormatter.
Five class methods are built that have the same names as the instance methods: debug, info, warn, error and fatal. Their arguments are different, however, being the message to be logged and optionally, one or more Loggers to log the message. If no Loggers are passed, the default is used, and if that is nil,no logging takes place.
Two other convenience class methods for each of the five Logger severities are also provided for checking and adjusting the threshold levels of the default logger. The debug?, info?, warn?, error? and fatal? methods return true if a message at that level will be reported by the default logger. Respectively, the level_debug, level_info, level_warn, level_error and level_fatal methods will set the threshold of the default logger to pass only messages at or above the selected severity.
classify | [RW] |
Sets the default logger to nil, indicating that further logging by the class through the default logger mechanism is disabled.
Creates a new EasyLogger instance. Logging is recorded through the given logdev, either an IO stream or to a file when logdev is a String containing its filename. Shift age is either the number of log files to keep, or the frequency of rotation. Shift size is the maximum logfile size, applicable when shift age is a number. Subsecond precision is the number of decimal places that express fractional seconds. If this is the first instance being created, it is remembered and used by the logging methods at the class level as the default logger.