TB2::Event::Log - a logging event
This is an Event representing a message not directly associated with a result. For example, informing the user which database the test is using.
Each event has a level associated with it to indicate how important it is referred to as "priority". This is modeled on syslog. Here is descriptions of each log level from highest to lowest priority.
This will always be the highest prioirty level and is only used for sorting and comparison purposes. An event cannot have this level.
User intervention is required to proceed.
Used for messages indicating an unexpected error in the test.
Example: Uncaught exception, couldn't open a file, etc...
Typically used for messages about a failed test.
Example: a failing test or a passing todo test
Typically used for messages about an abnormal situtation which does not cause the test to fail.
Example: a skipped or failing todo test
Information about the test useful for debugging a failure or rerunning the test in the same way but of no value if the test passed normally.
Example: temp file names, random number seeds, SQL queries
Information about the internal workings of the assert functions.
This will always be the lowest prioirty level and is only used for sorting and comparison purposes. An event cannot have this level.
New levels may be introduced. So when determining if a level should be displayed, care should be taken to always work in ranges of levels else a newly introduced level might be missed. The primary mechanism is to call between_levels.
# alert or higher if( $event->between_levels("alert", "highest") ) { alert($event->message); } # warning up to, but not including, alert elsif( $event->between_levels("warning", "alert") ) { print STDERR $event->message; } # everything up to, but not including, warning else { log($event->message); }
The event type is log
log
my @levels = $event->levels;
Returns the names of logging levels, as strings, in order from lowest to highest.
This does not include the notational levels.
$is_between = $event->between_levels($low_level, $high_level);
Returns true if $event->level is greater than or equal to $low_level and less than $high_level, false otherwise.
$event->level
In set theory that's [$low_level, $high_level).
[$low_level, $high_level)
The text associated with this log.
The severity level of this log message. See Levels for the possible values and what they mean.
Defaults to debug.
debug
A valid level for a TB2::Event::Log
To install Test::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Simple
CPAN shell
perl -MCPAN -e shell install Test::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.