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

NAME

Log::Dispatch::File::Alerts - Object for logging to alert files

SYNOPSIS

  use Log::Dispatch::File::Alerts;

  my $file = Log::Dispatch::File::Alerts->new(
                             name      => 'file1',
                             min_level => 'emerg',
                             filename  => 'Somefile%d{yyyy!!!!}.log',
                             mode      => 'append' );

  $file->log( level => 'emerg',
              message => "I've fallen and I can't get up\n" );

ABSTRACT

This module provides an object for logging to files under the Log::Dispatch::* system.

DESCRIPTION

This module subclasses Log::Dispatch::File for logging to date/time stamped files. See Log::Dispatch::File for instructions on usage. This module differs only on the following three points:

alert files

This module will use a seperate file for every log message.

multitasking-safe

This module uses flock() to lock the file while writing to it.

stamped filenames

This module supports a special tag in the filename that will expand to the current date/time/pid.

It is the same tag Log::Log4perl::Layout::PatternLayout uses, see Log::Log4perl::Layout::PatternLayout, chapter "Fine-tune the date". In short: Include a "%d{...}" in the filename where "..." is a format string according to the SimpleDateFormat in the Java World (http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html). See also Log::Log4perl::DateFormat for information about further restrictions.

In addition to the format provided by Log::Log4perl::DateFormat this module also supports '$' for inserting the PID and '!' for inserting a uniq number. Repeat the character to define how many character wide the field should be.

A note on the '!': The module first tries to find a fresh filename with this set to 1. If there is already a file with that name then it is increased until either a free filename has been found. If there is no free filename (e.g. you used '!!' and there are already 100 files) or the counter goes over the top (integer overflow) the module dies. So if you used many '!'s and there are many alert files, this can take quite a while. But if you have that many alert files, something already went very bad, so it should not really matter.

METHODS

new()

See Log::Dispatch::File and chapter DESCRIPTION above.

log_message()

See Log::Dispatch::File and chapter DESCRIPTION above.

HISTORY

0.99

Original version; taken from Log::Dispatch::File::Rolling 1.02

1.00

Initial coding

1.01

Updated packaging for newer standards. No changes to the coding.

1.02

Added unlocking of files we do not use.

Removed the 9999 files limit. Now it will create as many files as a Perl integer can support.

SEE ALSO

Log::Dispatch::File, Log::Log4perl::Layout::PatternLayout, Log::Dispatch::File::Rolling, Log::Log4perl::DateFormat, http://java.sun.com/j2se/1.3/docs/api/java/text/SimpleDateFormat.html, 'perldoc -f flock'

AUTHOR

M. Jacob, <jacob@j-e-b.net>

COPYRIGHT AND LICENSE

Copyright (C) 2003, 2007, 2010 M. Jacob <jacob@j-e-b.net>

Based on:

  Log::Dispatch::File::Stamped by Eric Cholet <cholet@logilune.com>
  Log::Dispatch::FileRotate by Mark Pfeiffer, <markpf@mlp-consulting.com.au>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.