Log::Agent::Driver::File - file logging driver for Log::Agent
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);
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
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:
error
output
debug
-magic_open
-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
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
This switch supersedes both -duperr and -channels by defining a single file for all the channels.
When true, channel filenames beginning with '>' or '|' are opened using Perl's open(). Otherwise, sysopen() is used, in append mode.
-prefix
The application prefix string to prepend to messages.
-showpid
If set to true, the PID of the process will be appended within square brackets after the prefix, to all messages.
-stampfmt
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.
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.
Raphael Manfredi <Raphael_Manfredi@pobox.com>
Log::Agent::Driver(3), Log::Agent(3).
To install Log::Agent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Log::Agent
CPAN shell
perl -MCPAN -e shell install Log::Agent
For more information on module installation, please visit the detailed CPAN module installation guide.