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.
- 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 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 %W. A %E is a error. As the rules are done in order, '%E stopping due to warnings' is actually 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->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_stderr
-
write_stderr prints to the screen any errors or warnings that were found in the logfile.
SEE ALSO
DISTRIBUTION
The latest version is available from CPAN and from http://veripool.com/
.
AUTHORS
Wilson Snyder <wsnyder@wsnyder.org>