Munin::Common::Logger(3) Perl extension for blah blah blah

SYNOPSIS


use Munin::Common::Logger;
DEBUG("blah, blah, blah");
INFO("blah, blah, blah");
NOTICE("blah, blah, blah");
WARNING("blah, blah, blah");
ERROR("blah, blah, blah");
CRITICAL("blah, blah, blah");
ALERT("blah, blah, blah");
EMERGENCY("oops");
LOGCROAK("Goodbye, world!");
DEBUG(slow_and_expensive_operation) if Munin::Common::Logger::would_log('debug');
Munin::Common::Logger::configure( level => 'debug') if $debug;

DESCRIPTION

Munin::Common::Logger handles logging for Munin.

It uses Log::Dispatch for this, and exports utility functions to enable logging from other parts of Munin.

To help transition from previous logging modules:

Functions are similar to Log4perl
The functions used are similar to Log4perl, to make the number of code changes minimal.
Log messages are changed
The ``[SEVERITY]'' prefix in the existing log messages are removed by Munin::Common::Logger. Severity is set by the function used to log, and used in the output formatting.

EXPORT

The functions DEBUG, INFO, NOTICE, WARNING, ERROR, CRITICAL, ALERT, EMERGENCY and LOGCROAK are exported by default.

FUNCTIONS

configure { level => $level, output => $output }
  configure { level => 'error', output => 'screen'}
  configure { level => 'debug', output => 'syslog'}

Removes the default logging, and replaces it with the configured log output.

Option ``level'' sets the minimum log level. Takes one argument, which is the log level to accept. Optional, default is ``warning''.

See Log::Dispatch for a list of valid log levels.

Option ``output'' sets the log output. Valid outputs are 'screen' and 'syslog'. Optional, default is ``syslog''.

would_log
Returns true if a message would be logged given the log level. Takes one argument, which is the log level to check.

Use this around expensive log statements, to skip them if they would not be logged.

See Log::Dispatch for a list of valid log levels.

DEBUG
Log with DEBUG priority. Takes one argument, which is the string to log.
INFO
Log with INFO priority. Takes one argument, which is the string to log.
NOTICE
Log with NOTICE priority. Takes one argument, which is the string to log.
WARN
Log with WARNING priority. Takes one argument, which is the string to log.
WARNING
Log with WARNING priority. Takes one argument, which is the string to log.
ERROR
Log with ERROR priority. Takes one argument, which is the string to log.
CRITICAL
Log with CRITICAL priority. Takes one argument, which is the string to log.
EMERGENCY
Log with EMERGENCY priority. Takes one argument, which is the string to log.
ALERT
Log with ALERT priority. Takes one argument, which is the string to log.
FATAL
Log with FATAL priority. Takes one argument, which is the string to log.
LOGCROAK
Log with CRITIAL priority exit the program. Takes one argument, which is the string to log.

See also "log_and_croak" in Log::Dispatch.

AUTHOR

Stig Sandbeck Mathisen, <[email protected]>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Stig Sandbeck Mathisen

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.2 or, at your option, any later version of Perl 5 you may have available.

BUGS

None reported... yet.