DNSCheck::Logger(3)

NAME
DNSCheck::Logger - Logger Subsystem

DESCRIPTION
The logger object keeps track of the results from the DNSCheck system.

METHODS

->new();
    Object creation. Do not use this, use the DNSCheck::logger() method.

set_filter($tag, $arglistref, $new_level)
    Add a log entry filter. When a message with the given tag is added, the arguments for it are compared to the ones given with the filter. If all the provided arguments are stringwise equal to the ones logged, the level for that log entry will be set to the one given by the filter. This way, an expected message can be given a different level than other messages of the same type. This way, for example, known false positives can be suppressed.

    It is also possible to set filters via the configuration file. The format for that is described in DNSCheck::Overview in the config file section.

remove_filters_for($tag)
    Remove all filters for a given tag.

check_filters($level, $tag, @args)
    Used internally to implement the filter functionality.

callback($coderef)
    Set a coderef that will be called as a method every time a message is added, with the message as its argument. The message will be in the format internally used by the logger.

->clear();
    Delete all current content in the object.

->parent()
    Get a reference to the parent 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.

->add(level, tag, arg1, arg2, ..., argN)
    Add an entry to the log, hardcoding the severity level instead of having it automatically looked up in the policy database. Don't do that.

->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. Each message is an array ref with the following values:

    0 - timestamp
    1 - logname
    2 - level
    3 - tag
    4 - module_id
    5 - parent_module_id
    Above 5 - arguemnts

    See "LOG ENTRIES" for an explanation of these.

->export_hash();
    Like export(), but returns a list of hashes, each with keys corresponding to those described in "LOG ENTRIES", with the following addition:

    •   logname - the logname attribute, or the empty string if not set.

->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.

->count_string($string)
    Returns the number of current entries where the severity equals the given string. This is used to implement the preceeding methods.

->locale()
    Return a locale object, which can be used to translate logger messages to human-readable messages. You shouldn't need to call it directly, since the logger does it for you

->module_stack_pop()
->module_stack_push()
    These two methods are part of the integrated communication with the PHP web GUI.

LOG ENTRIES
Each entry in the log is a hash. The export_hash() 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.

EXAMPLES
    use DNSCheck;

    my $dc = DNSCheck->new;

    $dc->zone->test("iis.se");

    while (defined(my $entry = $dc->logger->get_next_entry)) {
        print $entry->{tag}
    }