DNSCheck::Logger - Logger Subsystem
The logger object keeps track of the results from the DNSCheck system.
- ->new();
- Object creation. Do not use this, use the DNSCheck::logger()
method.
- ->clear();
- Delete all current content in the object.
- ->logname($name);
- Set the log name.
- ->auto(tag, arg1, arg2, ..., argN);
- Add an entry to the log. You should only need to use this if you're
writing more tests for DNSCheck. The tag needs to be defined in the locale
YAML file, and the number of arguments specified there must match the
number given when calling the method.
If the interactive key is set in the system's config
object, this method will print the log entry rather than store it
internally.
- ->dump();
- Send a textual raw dump of the object's contents to standard error.
- ->print();
- Send a textual dump of the object's contents to standard output. If a
locale is set, the output will be translated from raw tags to
human-readable messages.
- ->export();
- Return a list with all messages currently in the object.
- ->get_next_entry()
- Returns a hashref with the next log entry. If this method has never been
alled before on this object, the "next" entry is the first one.
It will then iterate through the entries until all have been returned, and
after that it will return "undef". It is
possible to add more entries without upsetting the iterator. This is,
however, not really the intened use. The purpose is to be able to process
all log entries without needing to know anything about their storage or
copying possibly large arrays. See below for an example of use.
- ->count_debug
- ->count_info
- ->count_notice
- ->count_warning
- ->count_error
- ->count_critical
- Returns the number of current entries of the various severity levels. The
level a given tag is considered to be is specified in
policy.yaml.
Each entry in the log is a hash. The export() and get_next_entry()
methods return them, as a list or one at a time. There are a bunch of keys in
the hashes:
- tag
- The message tag, as given when the entry was added. If it can't be found
in policy.yaml, it'll be considered to have no arguments and be of
level DEBUG.
- timestamp
- The time when the entry was added, as a string representing a float value
in seconds since the Unix epoch.
- level
- The severity level, as taken from policy.yaml.
- arg
- A reference to a list with message arguments.
- module_id
- parent_module_id
- Numbers that represent the call hieararchy of test modules. Used by the
standard web gui.
use DNSCheck;
my $dc = DNSCheck->new;
$dc->zone->test("iis.se");
while (defined(my $entry = $dc->logger->get_next_entry)) {
print $entry->{tag}
}