CAF::Log - Simple class for handling log files
use CAF::Log; my $log = CAF::Log->new('/foo/bar', 'at'); $log->print("this goes to the log file\n"); $log->close();
The CAF::Log class allows to instantiate objects for writing log files. A log file line can be prefixed by a time stamp.
closes the log file, returns SUCCESS on success, undef otherwise (if no FH attribute exists).
$msginto the log file.
PROCIDattribute is defined (value is irrelevant), the proces id in square brackets (
[PID]) and additional space are prepended.
TSTAMPattribute is defined (value is irrelevant), a
YYYY/MM/DD-HH:mm:sstimestamp and additional space are prepended.
No newline is added to the message.
Returns the return value of invocation of FH print method.
$optionsis a string with magic letters
- a: append to a logfile
- w: truncate a loglfile
- t: generate a timestamp on every print
- p: add PID
Only one of
acan and has to be set. (There is no default.)
woption is used and there was a previous log file, it is renamed with the extension '.prev'.
Examples: CAF::Log->new('/foo/bar', 'at'): append, enable timestamp CAF::Log->new('/foo/bar', 'w') : truncate logfile, no timestamp
If the filename ends with
SYSLOGattribute is set to basename of the file without suffix (relevant for CAF::Reporter::syslog).
Called during garbage collection. Invokes close().