The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

FleetConf::Log - A simple logger for FleetConf

SYNOPSIS

  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");

DESCRIPTION

This provides a convenient logging API that won't change even if FleetConf changes underlying logger APIs.

This API provides the following methods:

$log = FleetConf::Log->get_logger($namespace)

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.

$log->log($level, @msg)

This method is the main log method. You can pick your level with one of the following scalar strings:

debug4
debug3
debug2
debug1
debug
info
notice
warning
error
alert
emergency

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).

@log->debug4(@msg)
$log->debug3(@msg)
$log->debug2(@msg)
$log->debug1(@msg)
$log->debug(@msg)
$log->info(@msg)
$log->notice(@msg)
$log->warning(@msg)
$log->error(@msg)
$log->alert(@msg)
$log->emergency(@msg)

These are shortcuts for the log() method. That is, this code snippet:

  $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().

$test = $log->would_log($level)

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.

AUTHOR

Andrew Sterling Hanenkamp, <hanenkamp@users.sourceforge.net>

COPYRIGHT AND LICENSE

Copyright 2005 Andrew Sterling Hanenkamp. All Rights Reserved.

FleetConf is distributed and licensed under the same terms as Perl itself.