FleetConf::Log - A simple logger for FleetConf
use FleetConf::Log; $log = FleetConf::Log->get_logger(__PACKAGE__); $log->debug("Debug it"); $log->info("Give some info"); $log->notice("Notice this"); $log->warning("I'm warning you"); $log->error("Uh-oh, an error"); $log->alert("Alert: very bad stuff"); $log->emergency("This is an emergency"); $log->would_log("info") && $log->info("A really big dump: ", Dumper($foo)); $level = "info"; $log->log($level, "Another way to log");
This provides a convenient logging API that won't change even if FleetConf changes underlying logger APIs.
This API provides the following methods:
This factory method must be called prior to any other to get an instance of the logger. The $namespace argument is optional, but it is helpful as a quick reference to logging information.
$namespace
This method is the main log method. You can pick your level with one of the following scalar strings:
Out of these "debug1" is the same as "debug".
The message is passed as one or more scalars in a list that is then joined together using the output field separator, $, (a.k.a. $OUTPUT_FIELD_SEPARATOR or $OFS, if you use English).
$,
$OUTPUT_FIELD_SEPARATOR
$OFS
use English
These are shortcuts for the log() method. That is, this code snippet:
log()
$log = FleetConf::Log->get_logger; for $level (qw( debug info notice warning error alert emergency) ) { $log->$level("Output something!"); }
has the same effect as:
$log = FleetConf::Log->get_logger; for $level (qw( debug info notice warning error alert emergency) ) { $log->log($level, "Output something!"); }
The @msg is concatenated together using the same process as log().
@msg
This allows the module using the logger to determine if logging at the given level will have any output or effect. This method can be used to keep the program from doing complicated or time/processor-consuming work.
Andrew Sterling Hanenkamp, <hanenkamp@users.sourceforge.net>
Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved.
FleetConf is distributed and licensed under the same terms as Perl itself.
To install FleetConf, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FleetConf
CPAN shell
perl -MCPAN -e shell install FleetConf
For more information on module installation, please visit the detailed CPAN module installation guide.