Log::Fine::Utils - Functional wrapper around Log::Fine
Provides a functional wrapper around Log::Fine.
use Log::Fine::Handle; use Log::Fine::Handle::File; use Log::Fine::Handle::Syslog; use Log::Fine::Levels::Syslog; use Log::Fine::Utils; use Sys::Syslog; # Set up some handles as you normally would. First, a handler for # file logging: my $handle1 = Log::Fine::Handle::File ->new( name => "file0", mask => Log::Fine::Levels::Syslog->bitmaskAll(), formatter => Log::Fine::Formatter::Basic->new() ); # And now a handle for syslog my $handle2 = Log::Fine::Handle::Syslog ->new( name => "syslog0", mask => LOGMASK_EMERG | LOGMASK_CRIT | LOGMASK_ERR, ident => $0, logopts => 'pid', facility => LOG_LEVEL0 ); # Open the logging subsystem with the default name "GENERIC" OpenLog( handles => [ $handle1, [$handle2], ... ], levelmap => "Syslog" ); # Open new logging object with name "aux". Note this will switch # the current logger to "aux" OpenLog( name => "aux", handles => [ $handle1, [[$handle2], [...] ]], levelmap => "Syslog" ); # Grab a ref to active logger my $current_logger = CurrentLogger(); # Get name of current logger my $loggername = $current_logger()->name(); # Switch back to GENERIC logger OpenLog( name => "GENERIC" ); # Grab a list of defined logger names my @names = ListLoggers(); # Log a message Log( INFO, "The angels have my blue box" );
The Utils class provides a functional wrapper for Log::Fine and friends, thus saving the developer the tedious task of mucking about in object-oriented land.
The following functions are automatically exported by Log::Fine::Utils:
Returns the currently "active" Log::Fine::Logger object
None
Currently active Log::Fine::Logger object
Provides list of currently defined loggers
Array containing list of currently defined loggers or undef if no loggers are defined
Logs the message at the given log level
level
Level at which to log
message
Message to log
1 on success
Opens the logging subsystem. If called with the name of a previously defined logger object, will switch to that logger, ignoring other given hash elements.
A hash containing the following keys:
handles
Either a single Log::Fine::Handle object or an array ref containing one or more Log::Fine::Handle objects
levelmap
[optional] Log::Fine::Levels subclass to use. Will default to "Syslog" if not defined.
name
[optional] Name of logger. If name references an already registered logger, then will switch to the named logger. Should the given name not exist, then will create a new logging object with that name, provided handles are provided. Should name not be passed, then 'GENERIC' will be used. Note that you must provide one or more valid handles when creating a new object.
no_croak
[default: 0] If true, Log::Fine will not croak under certain circumstances (see Log::Fine)
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?Queue=Log-Fine. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-log-fine at rt.cpan.org
OpenLog() will croak regardless if {no_croak} is set if the following two conditions are met:
{no_croak}
OpenLog() is passed the name of an unknown logger, thus necessitating the creation of a new logger object
No Log::Fine::Handle objects were passed in the {handles} array
{handles}
You can find documentation for this module with the perldoc command.
perldoc Log::Fine
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Log-Fine
CPAN Ratings
http://cpanratings.perl.org/d/Log-Fine
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Log-Fine
Search CPAN
http://search.cpan.org/dist/Log-Fine
Christopher M. Fuhrman, <cfuhrman at panix.com>
<cfuhrman at panix.com>
perl, Log::Fine, Log::Fine::Handle, Log::Fine::Logger
Copyright (c) 2008, 2010-2011, 2013 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.
To install Log::Fine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Fine
CPAN shell
perl -MCPAN -e shell install Log::Fine
For more information on module installation, please visit the detailed CPAN module installation guide.