Wombat::Logger::LoggerBase - logger base class
package My::Logger;
use base qw(Wombat::Logger::LoggerBase);
Convenience base class for logger implementations. The only method
that must be implemented is write()
, plus any accessor methods
required for configuration, and start()
and stop()
if resources
must be initialized and cleaned up.
new()
-
Construct and return a Wombat::Logger::LoggerBase instance,
initializing fields appropriately. If subclasses override the
constructor, they must be sure to call
$self->SUPER::new();
getContainer()
-
Return the Container with which this Logger is associated.
setContainer($container)
-
Set the Container with which this Logger is associated.
Parameters:
- $container
-
the Container with which this Logger is associated
getLevel()
-
Return the verbosity level of this Logger.
setLevel($level)
-
Set the verbosity level of this Logger. Messages logged with a higher
verbosity than this will be silently ignored.
Allowable values in increasing order are:
- 'FATAL'
-
- 'ERROR'
-
- 'WARNING'
-
- 'INFO'
-
- 'DEBUG'
-
The default level is 'ERROR'.
Parameters:
- $level
-
the verbosity level, as a string
Throws:
- Servlet::Util::IllegalArgumentException
-
if the specified log level is not one of the allowed values
- log($message, $exception, $level)
-
Send a message and/or an exception to the log destination. If a level
is specified, the Logger must be set to a verbosity level greater than
or equal to the specified level. If a level is not specified, the
message and/or exception will be logged unconditionally.
Parameters:
- $message
-
an optional string message to log
- $exception
-
an optional exception to log in stack trace form
- $level
-
an optional log level
write($string)
-
Write the specified string to the log destination. The default
implementation does nothing. Subclasses must override this method.
Parameters:
- $string
-
the string to write to the log destination
start()
-
Prepare for the beginning of active use of this Logger. This method
must be called before any of the public methods of the component are
utilized. Subclasses should initialize logging resources with this
method.
Throws:
- Wombat::LifecycleException
-
if the Logger cannot be started
stop()
-
Gracefully terminate the active use of this Logger. This method must
be the last called on a given instance of this component. Subclasses
should release logging resources with this method.
Throws:
- Wombat::LifecycleException
-
if the Logger cannot be stopped
the Servlet::Util::Exception manpage,
the Wombat::Exception manpage
Brian Moseley, bcm@maz.org