| Log::Fine - Yet another logging framework |
Log::Fine - Yet another logging framework
Provides fine-grained logging and tracing.
use Log::Fine;
use Log::Fine::Levels::Syslog; # exports log levels
use Log::Fine::Levels::Syslog qw( :masks ); # exports masks and levels
# build a Log::Fine object
my $fine = Log::Fine->new();
# specify a custom map
my $fine = Log::Fine->new(levelmap => "Syslog");
# use logger() to get a new logger object. If "foo" is not
# defined then a new logger with the name "foo" will be created.
my $log = Log::Fine->logger("foo");
# register a handle, in this case a handle that logs to console.
my $handle = Log::Fine::Handle::Console->new();
$log->registerHandle( $handle );
# log a message
$log->log(INFO, "Log object successfully initialized");
Log::Fine provides a logging framework for application developers who need a fine-grained logging mechanism in their program(s). By itself, Log::Fine provides a mechanism to get one or more logging objects (called loggers) from its stored namespace. Most logging is then done through a logger object that is specific to the application.
For a simple functional interface to the logging sub-system, see Log::Fine::Utils.
Handlers provides a means to output log messages in one or more ways. Currently, the following handles are provided:
Provides logging to STDERR or STDOUT
Provides logging to a file
Same thing with support for time-stamped files
Provides logging to syslog
See the relevant perldoc information for more information. Additional handlers can be defined to the user's taste.
A formatter specifies how Log::Fine displays messages. When a message is logged, it gets passed through a formatter object, which adds any additional information such as a time-stamp or caller information.
By default, log messages are formatted as follows using the Basic formatter object.
[<time>] <LEVEL> <MESSAGE>
For more information on the customization of log messages, see the Log::Fine::Formatter manpage.
The Log::Fine module, by itself, provides getters & setter methods for loggers and level classes. After a logger is created, further actions are done through the logger object. The following two constructors are defined:
Creates a new Log::Fine object.
A hash with the following keys
[default: Syslog] Name of level map to use. See the Log::Fine::Levels manpage for further details
[optional] If set to true, then do not croak when _fatal() is called.
The newly bless'd object
Getter for the global level map.
A the Log::Fine::Levels manpage subclass
Getter/Constructor for a logger object.
The name of the logger object. If the specified logger object does not exist, then a new one will be created.
an the Log::Fine::Logger manpage object
Private method that is called when a fatal (nonrecoverable) condition is encountered. Will call croak unless the {no_croak} attribute is set.
This method can be overridden per taste.
Message passed to croak.
I'd like the thank the following people for either inspiration or past work on logging: Josh Glover for his work as well as teaching me all I know about object-oriented programming in perl. Dan Boger for taking the time and patience to review this code and offer his own suggestions. Additional thanks to Tom Maher and Chris Josephs for encouragement.
The following logging frameworks provided inspiration for parts of Log::Fine.
Dave Rolsky's the Log::Dispatch manpage module
Sun Microsystem's java.utils.logging framework
The Python logging package
perl, syslog, the Log::Fine::Handle manpage, the Log::Fine::Formatter manpage, the Log::Fine::Logger manpage, the Log::Fine::Utils manpage, the Sys::Syslog manpage
Christopher M. Fuhrman, <cfuhrman at panix.com>
Please report any bugs or feature requests to
bug-log-fine at rt.cpan.org, or through the web interface at
http://rt.cpan.org/NoAuth/ReportBug.html.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc Log::Fine
You can also look for information at:
Want to contribute? The source code repository for Log::Fine is now available at http://github.com/cfuhrman/log-fine. To clone your own copy:
$ git clone git://github.com/cfuhrman/log-fine.git
Signed patches generated by git-format-patch(1) may be submitted via email.
$Id: 3cdb9b7f8436503e5cc78247cdb183280ff73b5a $
Copyright (c) 2008, 2009, 2010 Christopher M. Fuhrman, All rights reserved.
This program is free software licensed under the...
The BSD License
The full text of the license can be found in the LICENSE file included with this module.
| Log::Fine - Yet another logging framework |