Log::Dispatch::File::Stamped - Logging to date/time stamped files


Log-Dispatch-File-Stamped documentation  | view source Contained in the Log-Dispatch-File-Stamped distribution.

Index


NAME

Top

Log::Dispatch::File::Stamped - Logging to date/time stamped files

SYNOPSIS

Top

  use Log::Dispatch::File::Stamped;

  my $file = Log::Dispatch::File::Stamped->new(
    name      => 'file1',
    min_level => 'info',
    filename  => 'Somefile.log',
    stamp_fmt => '%Y%m%d',
    mode      => 'append' );

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

DESCRIPTION

Top

This module subclasses Log::Dispatch::File for logging to date/time stamped files.

METHODS

Top

new(%p)

This method takes the same set of parameters as Log::Dispatch::File::new(), with the following differences:

-- filename ($)

The filename template. The actual timestamp will be appended to this filename when creating the actual logfile. If the filename has an extension, the timestamp is inserted before the extension. See examples below.

-- stamp_fmt ($)

The format of the timestamp string. This module uses POSIX::strftime to create the timestamp string from the current local date and time. Refer to your platform's strftime documentation for the list of allowed tokens.

Defaults to '%Y%m%d'.

-- binmode ($)

A layer name to be passed to binmode, like ":utf8" or ":raw".

-- mode ($)

This parameter is ignored, and is forced to 'append'.

log_message( message => $ )

Sends a message to the appropriate output. Generally this shouldn't be called directly but should be called through the "log()" method (in Log::Dispatch::Output).

EXAMPLES

Top

Assuming the current date and time is:

  % perl -e 'print scalar localtime'
  Sat Feb  8 13:56:13 2003

  Log::Dispatch::File::Stamped->new(
    name      => 'file',
    min_level => 'debug',
    filename  => 'logfile.txt',
  );

This will log to file 'logfile-20030208.txt'.

  Log::Dispatch::File::Stamped->new(
    name      => 'file',
    min_level => 'debug',
    filename  => 'logfile.txt',
    stamp_fmt => '%d%H',
  );

This will log to file 'logfile-0813.txt'.

SEE ALSO

Top

Log::Dispatch::File, POSIX.

AUTHOR

Top

Eric Cholet <cholet@logilune.com>

COPYRIGHT

Top

ACKNOWLEDGEMENTS

Top

Dave Rolsky, author of the Log::Dispatch suite and many other fine modules on CPAN.


Log-Dispatch-File-Stamped documentation  | view source Contained in the Log-Dispatch-File-Stamped distribution.