CTKlib

 view release on metacpan or  search on metacpan

lib/CTK/Log.pm  view on Meta::CPAN

package CTK::Log;
use strict;
use utf8;

=encoding utf-8

=head1 NAME

CTK::Log - CTK Logging

=head1 VERSION

Version 2.64

=head1 SYNOPSIS

    use CTK::Log;
    use CTK::Log qw/:constants/;

    my $logger = CTK::Logger->new (
            file        => "logs/foo.log",
            level       => CTK::Log::LOG_INFO,
            ident       => "ident string",
        );

    $logger->log( CTK::Log::LOG_INFO, " ... Blah-Blah-Blah ... " );

    $logger->log_except( "..." );  # 9 exception, aborts program!
    $logger->log_fatal( "..." );   # 8 system unusable, aborts program!
    $logger->log_emerg( "..." );   # 7 system is unusable
    $logger->log_alert( "..." );   # 6 failure in primary system
    $logger->log_crit( "..." );    # 5 failure in backup system
    $logger->log_error( "..." );   # 4 non-urgent program errors, a bug
    $logger->log_warning( "..." ); # 3 possible problem, not necessarily error
    $logger->log_notice( "..." );  # 2 unusual conditions
    $logger->log_info( "..." );    # 1 normal messages, no action required
    $logger->log_debug( "..." );   # 0 debugging messages (default)

=head1 DESCRIPTION

Logger class

Log level overview:

   LVL SLL NAME      ALIAS    NOTE
    0   7  debug              debugging messages, copious tracing output
    1   6  info               normal messages, no action required
    2   5  notice    note     unusual conditions
    3   4  warning   warn     possible problem, not necessarily error
    4   3  error     err      non-urgent program errors, a bug
    5   2  critical  crit     failure in backup system
    6   1  alert              failure in primary system
    7   0  emergency emerg    system unusable
    8   0  fatal              system unusable, aborts program!
    9   0  exception except   exception, aborts program!

* SLL -- SysLog Level

=head1 METHODS

=head2 new

    my $logger = CTK::Log->new(
            file        => "logs/foo.log",
            level       => "info", # or CTK::Log::LOG_INFO
            ident       => "ident string",
        );

Returns logger object for logging to file

    my $logger = CTK::Log->new(
            level       => "info", # or CTK::Log::LOG_INFO
            ident       => "ident string",
        );

Returns logger object for logging to syslog

=over 8

=item B<facility>

The part of the system to report about, for example C<Sys::Syslog::LOG_USER>. See L<Sys::Syslog>

Default: C<Sys::Syslog::LOG_USER>

=item B<file>

Specifies log file. If not specify, then will be used syslog

Default: undef

=item B<ident>

Specifies ident string for each log-record

  ident = "test"

    [Mon Apr 29 20:02:04 2019] [info] [7936] [test] Blah Blah Blah

  ident = undef

    [Mon Apr 29 20:02:04 2019] [info] [7936] Blah Blah Blah

Default: undef

=item B<level>

This directive specifies the minimum possible priority level. You can use:

constants:



( run in 0.759 second using v1.01-cache-2.11-cpan-df04353d9ac )