NAME

Log::Agent::Driver::File - file logging driver for Log::Agent

SYNOPSIS

use Log::Agent;
require Log::Agent::Driver::File;

my $driver = Log::Agent::Driver::File->make(
    -prefix     => "prefix",
    -duperr     => 1,
    -stampfmt   => "own",
    -showpid    => 1,
    -magic_open => 0,
    -channels   => {
       'error'   => '/tmp/output.err',
       'output'  => 'log.out',
       'debug'   => '../appli.debug',
    },
);
logconfig(-driver => $driver);

DESCRIPTION

The file logging driver redirects logxxx() operations to specified files, one per channel usually (but channels may go to the same file).

The creation routine make() takes the following arguments:

-channels => hash ref

Specifies where channels go. The supplied hash maps channel names (error, output and debug) to filenames. When -magic_open is set to true, filenames are allowed magic processing via perl's open(), so this allows things like:

-channels => {
    'error'   => '>&FILE',
    'output'  => '>newlog',   # recreate each time, don't append
    'debug'  => '|mailx -s whatever user',
}

If a channel (e.g. 'output') is not specified, it will go to the 'error' channel, and if that one is not specified either, it will go to STDERR instead.

-duperr => flag

When true, all messages normally sent to the error channel are also copied to the output channel with a prefixing made to clearly mark them as such: "FATAL: " for logdie() and logconfess(), "ERROR: " for logerr() and "WARNING: " for logwarn().

Default is false.

-file => file

This switch supersedes both -duperr and -channels by defining a single file for all the channels.

-magic_open => flag

When true, channel filenames beginning with '>' or '|' are opened using Perl's open(). Otherwise, sysopen() is used, in append mode.

Default is false.

-prefix => prefix

The application prefix string to prepend to messages.

-showpid => flag

If set to true, the PID of the process will be appended within square brackets after the prefix, to all messages.

Default is false.

-stampfmt => (name | CODE)

Specifies the time stamp format to use. By default, my "own" format is used. The following formats are available:

date      "[Fri Oct 22 16:23:10 1999]"
none
own       "99/10/24 09:43:49"
syslog    "Oct 27 21:09:33".

You may also specify a CODE ref: that routine will be called every time we need to compute a time stamp. It should not expect any parameter, and should return a string.

CHANNELS

All the channels go to the specified files. If a channel is not configured, it is redirected to 'error', or STDERR if no 'error' channel was configured either.

AUTHOR

Raphael Manfredi <Raphael_Manfredi@pobox.com>

SEE ALSO

Log::Agent::Driver(3), Log::Agent(3).