The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

XAS::Lib::Modules::Log - A class for logging in the XAS Environment

SYNOPSIS

    use XAS::Lib::Modules::Log;

    my $log = XAS::Lib::Modules::Log->new();

    $log->debug('a debug message');
    $log->info('an info message');
    $log->warn('a warning message');
    $log->error('an error message');
    $log->fatal('a fatal error message');
    $log->trace('a tracing message');

DESCRIPTION

This module defines a simple logger for messages generated by an application. It is intentionally very simple in design, providing the bare minimum in functionality with the possibility for extension by sub-classing.

METHODS

new

This will initialize the base object. It takes the following parameters:

-type

The type of the log. This can be "console", "file", "logstash" or "syslog". Defaults to "console". Which means all logging goes to the current terminal.

-filename

The name of the log file. This only is relevant if the log type is "file".

-facility

The facility of the log message. Primarily has meaning when using a log type of "logstash" or "syslog". The following have been defined and follows the syslog standard.

    auth, authpriv, cron, daemon, ftp,
    local[0-7], lpr, mail, news, user, uucp

Defaults to "local7".

-process

The name of the process. Defaults to "XAS", which is not to useful.

-levels

A hashref of values to set the internal logging level with.

Example:

    my $log = XAS::Lib::Modules::Log->new(
        -levels => {
            debug => $self->debugging ? 1 : 0,
        }
    );

This would set the debug level of logging, depending on the value of $self->debugging.

level($level, $boolean)

This will query or toggle the log level. When toggled that particular level is set. There is no hierarchy of log levels.

$level

The log level to toggle. This can be one of the following:

 info, warn, error, fatal, debug, trace
$boolean

An optional valve. It needs to be 0 or 1 to set the level.

info($line)

This method will log an entry with an level of "info".

$line

The message to write out. This can be an array which will be joined with a "space" separator.

warn($line)

This method will log an entry with an level of "warn".

$line

The message to write out. This can be an array which will be joined with a "space" separator.

error($line)

This method will log an entry with an level of "error".

$line

The message to write out. This can be an array which will be joined with a "space" separator.

fatal($line)

This method will log an entry with an level of "fatal".

$line

The message to write out. This can be an array which will be joined with a "space" separator.

debug($line)

This method will log an entry with an level of "debug". By default this level is turned off.

$line

The message to write out. This can be an array which will be joined with a "space" separator.

trace($line)

This method will log an entry with an level of "trace".

$line

The line to write out. This can be an array which will be joined with a "space" separator.

info_msg($message, $line)

This method will log an entry with an level of "info".

$message

The message to apply line against. This should be defined in the package variable $MESSAGE or in the message stanza in XAS::Class.

$line

The line to write out. This can be an array which will be joined with a "space" separator.

warn_msg($message, $line)

This method will log an entry with an level of "warn".

$message

The message to apply line against. This should be defined in the package variable $MESSAGE or in the message stanza in XAS::Class.

$line

The line to write out. This can be an array which will be joined with a "space" separator.

error_msg($message, $line)

This method will log an entry with an level of "error".

$message

The message to apply line against. This should be defined in the package variable $MESSAGE or in the message stanza in XAS::Class.

$line

The line to write out. This can be an array which will be joined with a "space" separator.

fatal_msg($message, $line)

This method will log an entry with an level of "fatal".

$message

The message to apply line against. This should be defined in the package variable $MESSAGE or in the message stanza in XAS::Class.

$line

The line to write out. This can be an array which will be joined with a "space" separator.

debug_msg($message, $line)

This method will log an entry with an level of "debug".

$message

The message to apply line against. This should be defined in the package variable $MESSAGE or in the message stanza in XAS::Class.

$line

The line to write out. This can be an array which will be joined with a "space" separator.

trace_msg($message, $line)

This method will log an entry with an level of "trace".

$message

The message to apply line against. This should be defined in the package variable $MESSAGE or in the message stanza in XAS::Class.

$line

The line to write out. This can be an array which will be joined with a "space" separator.

SEE ALSO

XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (C) 2014 Kevin L. Esteb

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

See http://dev.perl.org/licenses/ for more information.