NAME
Log::Detect - Read logfiles to detect error and warning messages
SYNOPSIS
use Log::Detect; my $d = new Log::Detect (); $d->read(filename=>"test_dir/test.log"); $d->write_stdout(); $d->write_append();
DESCRIPTION
Log::Detect is used to read logfiles, and apply regexps to determine if the logfile contains any errors or warning messages. This is generally useful for those programs that refuse to return bad exit status when they should.
Log::Detect can also append a summary of all errors and warnings to the logfile, to a different file, or to the screen.
VARIABLES
These variables may be specified with the new function, or with the set function. Most member functions also accept any of these variables when they are called.
- dino
-
The default filename for write_dino.
- simvision
-
The default filename for write_simvision.
- program
-
The name of the program to prepend to error messages. Defaults to $0.
- time_regexp
-
A regexp where $1 returns the timestamp. Used by write_dino and write_simvision only.
- warn_fatal
-
If true, warnings are considered fatal errors. Defaults true.
- warn_finish
-
If true, lack of a regexp matching 'finish' is considered fatal.
- regexps
-
A list of actions and regular expressions. The regexps are matched against the text in order, with the first match action determining the result.
For example, the default: [warning => qr/Stopping due to warnings/i, error => qr/(?i)%E|\bError ?[:!-]|Fatal ?[:!-]|\] Error [0-9]/, warning => qr/%W/i, warning => qr/\bWarning ?[:!-]/i, finish => qr/\*-\* All Finished \*-\*/, ],
Specifies that a line matching "stopping due to warnings" is a warning, as is any line with %W (VMS's error messages). A %E on a matching line is signaled as an error. As the rules are done in order, if the file has the line '%E stopping due to warnings', which matches both the "%E" and the "stopping due to warnings" regexps, the first match wins, and thus the action indicates a warning, not an error.
FUNCTIONS
- $det->actions
-
Returns the list of parsed actions. Each list element is a reference to a Log::Detect::Action, which has four accessor functions. lineno is the line number the message was detected on. filename is the file the error came from. action is the action specified with the regexp. text is the line itself.
- $det->actions_sorted_line
-
Returns the parsed actions, sorted by line number.
- $det->add_regexp
-
Prepends new rules to the regexp list.
- $det->clear
-
Clears the list of parsed actions, as if a read had never occurred.
- $det->new
-
Constructs the class. Any variables described above may be passed to the constructor.
- $det->read
-
read parses the logfile specified with filename=>. Each line is compared against the regular expressions in turn, forming a list of actions.
- $det->set
-
set takes a named parameter list and sets those variables.
- $det->summary
-
summary returns a two element list. The first element is a text message describing if errors or warnings were found. The second contains the text lines from the file which had errors or warnings.
- $det->write_append
-
write_append appends to a file, by default the same exact logfile, any errors or warnings that were found.
- $det->write_dino
-
write_dino prints to a file Dinotrace annotations for any errors or warnings that were found in the logfile.
- $det->write_simvision
-
write_simvision prints to a file Simvision annotations for any errors or warnings that were found in the logfile.
- $det->write_stderr
-
write_stderr prints to the screen any errors or warnings that were found in the logfile.
DISTRIBUTION
The latest version is available from CPAN and from http://www.veripool.com/.
Copyright 2000-2005 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License or the Perl Artistic License.
AUTHORS
Wilson Snyder <wsnyder@wsnyder.org>