The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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.

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_dump

Return string summary of all matching actions.

$det->actions_sorted_line

Returns the parsed actions, sorted by line number.

$det->actions_sorted_limited

Returns the parsed actions, sorted by line number. Contains a maximum of report_limit number of errors.

$det->add_regexp

Prepends new rules to the regexp list.

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.

$det->clear

Clears the list of parsed actions, as if a read had never occurred.

$det->clear_regexps

Clears the list of regular expressions.

$det->new

Constructs the class. Any variables described above may be passed to the constructor.

$det->parse_eof

Call when the current parse_text is complete, and any partially completed messages should be emptied out.

$det->parse_text(text...)

Parse_text will check any parameters for error messages. If complete lines are not given, the line is buffered until more arrives.

You must call parse_start before the first call to this function, and must call parse_eof to avoid missing an error that is not newline terminated at the end of the file.

$det->parse_start( filename=>, lineno=> )

Called to indicate future calls will be made to parse_text.

$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

Log-Detect is part of the http://www.veripool.org/ free EDA software tool suite. The latest version is available from CPAN and from http://www.veripool.org/.

Copyright 2000-2009 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 Version 3 or the Perl Artistic License Version 2.0.

AUTHORS

Wilson Snyder <wsnyder@wsnyder.org>

SEE ALSO

Log::Delayed, vtrace