NAME
Log::Fu - Simple logging module and interface with absolutely no required boilerplate
DESCRIPTION
This is a simple interface for console logging. It provides a few functions, log_info
, log_debug
, log_warn
, log_crit
, and log_err
. They all take strings as arguments, and can take as many arguments as you so desire (so any concatenation is done for you).
A message is printed to standard error (or to $target if specified), prefixed with the filename, line number, and originating subroutine of the message. A format string might become available in the future
It is also possible to configure per-package logging parameters and level limitations. To do this, simply provide an option hashref when using the module, as shown in the synopsis. Available levels are: debug info warn err crit
Since this module uses a very plain and simple interface, it is easy to adjust your program to override these functions to wrap a more complex logging interface in the future.
There is very little boilerplate code for you to write, and it will normally just do its thing.
SYNOPSIS
use Miner::Logger { target => $some_filehandle, level => "info" };
log_debug("this is a debug level message");
log_info("this is an info-level message");
EXPORTED SYMBOLS
- log_$LEVEL($message1,$message2...,)
-
logs a message to the target specified at import with $LEVEL priority
- $SHUSH
-
Set this to a true value to silence all logging output
- $LINE_PREFIX
-
if set, each new line (not message) will be prefixed by this string.
PRIVATE SYMBOLS
These functions are subject to change and should not be used often. However they may be helpful in controlling logging when absolutely necessary
- _logger($numeric_level_constant, $level_display, $stack_offset, @messages)
-
$numeric_level_constant is a constant defined in this module, and is currently one of LOG_[WARN|DEBUG|ERR|INFO|CRIT]. $level_display is how to pretty-print the level.
A not-so-obvious parameter is $stack_offset, which is the amount of stack frames _logger should backtrack to get caller() info. All wrappers use a value of 1.
- log_$LEVEL_with_offset($offset, @messages)
-
like log_*, but allows to specify an offset. Useful in $SIG{__WARN__} or DIE functions
BUGS
None known
TODO
An optional (!!!) format string would be nice. Also, the ability to have functions like log_warnf instead of inserting log_warn sprintf.. statements all over
COPYRIGHT
Copyright 2011 M. Nunberg for Dynamite Data This module is dual-licensed as GPL/Perl Artistic. See README for details.