NAME
Test::Builder2::Event::Log - a logging event
DESCRIPTION
This is an Event representing a message not directly associated with a result. For example, informing the user which database the test is using.
Levels
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.
highest
This will always be the highest prioirty level and is only used for sorting and comparison purposes. An event cannot have this level.
alert
User intervention is required to proceed.
error
Used for messages indicating an unexpected error in the test.
Example: Uncaught exception, couldn't open a file, etc...
warning
Typically used for messages about a failed test.
Example: a failing test or a passing todo test
notice
Typically used for messages about an abnormal situtation which does not cause the test to fail.
Example: a skipped or failing todo test
info
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
debug
Information about the internal workings of the assert functions.
lowest
This will always be the lowest prioirty level and is only used for sorting and comparison purposes. An event cannot have this level.
Using Levels
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);
}
Methods
event_type
The event type is log
levels
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.
between_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.
In set theory that's [$low_level, $high_level)
.
Attributes
message
The text associated with this log.
level
The severity level of this log message. See Levels for the possible values and what they mean.
Defaults to debug
.
Types
Test::Builder2::LogLevel
A valid level for a Test::Builder2::Event::Log