NAME
Log::Delayed - Delay error handling and write status file
SYNOPSIS
use Log::Delayed; my $Delayed = new Log::Delayed (filename=>"test_dir/.status");
die_delayed ("First error into .status\n");
if ($Delayed->errors()) { print "We got a error\n"; } $Delayed->errors(0); # Clear errors
$Delayed->write_status();
my $current_status = $Delayed->read_status();
$Delayed->exit_if_error();
DESCRIPTION
Log::Delayed is used to delay error messages for later logging and exiting. This is useful when parsing files and such, and multiple errors want to be presented to the user before exiting the program.
In addition, Log::Delayed optionally makes a status file (.status), which contains the first error detected. This allows calling programs to be passed more useful tracking information then just the shell exit status.
FUNCTIONS
- $dly->new
-
New creates a new Log::Delayed object. Parameters are passed by named form. The filename=> parameter specifies the file to be written with the exit message, undef for none; defaults to .status. The global=> parameter forces the $dly->sig_end to be called automatically at program exit, it defaults true.
- $dly->die_delayed
-
Die_delayed prints any parameters on stderr, then records the error occurrence for later error exiting. If new was called with auto=>1 the exported version of die_delayed may be called without any object.
- $dly->errors
-
errors returns the number of errors seen. With a parameter it sets the number of errors seen.
- $dly->exit_if_error
-
exit_if_error exits the program if any errors were detected.
- $dly->read_status
-
read_status reads the filename=> specified with new or this function call. It returns the contents of the file, or undef if no file exists.
- $dly->sig_end
-
sig_end changes the exit status to be bad if any delayed errors were detected, and calls write_status. sig_end is called automatically by the END{} handler if global=>1 was specified with the new constructor.
- $dly->sig_die
-
sig_die records the first error it sees so that write_status will contain perl related error messages. sig_end is called automatically by the %SIG{__DIE__} handler if global=>1 was specified with the new constructor.
- $dly->write_status
-
write_status writes the filename=> specified with new or this function call with the first error message detected, or "Completed\n" if there were no errors.
SEE ALSO
Log::Detect, SIG{__DIE__} in perlvar
DISTRIBUTION
The latest version is available from CPAN and from http://veripool.com/
.
AUTHORS
Wilson Snyder <wsnyder@wsnyder.org>