NAME
CTK::Log - CTK Logging
VERSION
Version 2.63
SYNOPSIS
use CTK::Log;
use CTK::Log qw/:constants/;
my $logger = new CTK::Logger (
file => "logs/foo.log",
level => CTK::Log::LOG_INFO,
ident => "ident string",
);
$logger->log( CTK::Log::LOG_INFO, " ... Blah-Blah-Blah ... " );
$logger->log_except( "log message" ); # 9 exception
$logger->log_fatal( "log message" ); # 8 fatal
$logger->log_emerg( "log message" ); # 7 system is unusable
$logger->log_alert( "log message" ); # 6 action must be taken immediately
$logger->log_crit( "log message" ); # 5 critical conditions
$logger->log_error( "log message" ); # 4 error conditions
$logger->log_warning( "log message" ); # 3 warning conditions
$logger->log_notice( "log message" ); # 2 normal but significant condition
$logger->log_info( "log message" ); # 1 informational
$logger->log_debug( "log message" ); # 0 debug-level messages (default)
DESCRIPTION
Logger class
METHODS
new
my $logger = new CTK::Log (
file => "logs/foo.log",
level => "info", # or CTK::Log::LOG_INFO
ident => "ident string",
);
Returns logger object for logging to file
my $logger = new CTK::Log (
level => "info", # or CTK::Log::LOG_INFO
ident => "ident string",
);
Returns logger object for logging to syslog
- facility
-
The part of the system to report about, for example
Sys::Syslog::LOG_USER
. See Sys::SyslogDefault:
Sys::Syslog::LOG_USER
- file
-
Specifies log file. If not specify, then will be used syslog
Default: undef
- 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
- level
-
This directive specifies the minimum possible priority level. You can use:
constants:
LOG_DEBUG LOG_INFO LOG_NOTICE or LOG_NOTE LOG_WARNING or LOG_WARN LOG_ERR or LOG_ERROR LOG_CRIT LOG_ALERT LOG_EMERG or LOG_EMERGENCY LOG_FATAL LOG_EXCEPT or LOG_EXCEPTION
...or strings:
'debug' 'info' 'notice' or 'note' 'warning' or 'warn' 'error' or 'err' 'crit' 'alert' 'emerg' or 'emergency' 'fatal' 'except' or 'exception'
Default:
LOG_DEBUG
- pure
-
Specifies flag for suppressing prefixes log-data
ident = "test" pure = 0 [Mon Apr 29 19:12:55 2019] [crit] [7480] [test] Blah-Blah-Blah ident = "test" pure = 1 [test] Blah-Blah-Blah ident = undef pure = 1 Blah-Blah-Blah
Default: 0
- separator
-
Separator of log-record elements
separator = " " [Mon Apr 29 20:02:04 2019] [info] [7936] [test] Blah Blah Blah separator = "," [Mon Apr 29 20:02:04 2019],[info],[7936],[test],Blah Blah Blah
Default:
" "
- socketopts
-
Socket optrions for Sys::Syslog
Allowed formats, examples:
socketopts => "unix" socketopts => ["unix"] socketopts => { type => "tcp", port => 2486 }
Default:
native
- syslogopts
-
Options of Sys::Syslog
Default:
ndelay,pid
- usesyslog
-
Sets to 1 for send data to syslog forced
Default: 0
- utf8
-
Sets flag utf8 for logging data. The flag is enabled by default
Default: 1
error
my $error = $logger->error;
Returns error string if occurred any errors while creating the object
status
print $logger->error unless $logger->status;
Returns boolean status of object creating
LOG METHODS
log
$logger->log( <LEVEL>, <FORMAT>, <VALUE>, ... );
$logger->log( LOG_INFO, "Message: Blah-Blah-Blah" );
$logger->log( LOG_INFO, "Message: %s", "Blah-Blah-Blah" );
$logger->log( "info", "Message: Blah-Blah-Blah" );
Logging with info level (1). Same as log_info( "Message: %s", "Blah-Blah-Blah" )
log_debug
$logger->log_debug( <FORMAT>, <VALUE>, ... );
$logger->log_debug( "Blah-Blah-Blah" );
Level 0: debug-level messages (default)
log_info
$logger->log_info( <FORMAT>, <VALUE>, ... );
$logger->log_info( "Blah-Blah-Blah" );
Level 1: informational
log_notice, log_note
$logger->log_notice( <FORMAT>, <VALUE>, ... );
$logger->log_notice( "Blah-Blah-Blah" );
Level 2: normal but significant condition
log_warning, log_warn
$logger->log_warning( <FORMAT>, <VALUE>, ... );
$logger->log_warning( "Blah-Blah-Blah" );
Level 3: warning conditions
log_error, log_err
$logger->log_error( <FORMAT>, <VALUE>, ... );
$logger->log_error( "Blah-Blah-Blah" );
Level 4: error conditions
log_crit
$logger->log_crit( <FORMAT>, <VALUE>, ... );
$logger->log_crit( "Blah-Blah-Blah" );
Level 5: critical conditions
log_alert
$logger->log_alert( <FORMAT>, <VALUE>, ... );
$logger->log_alert( "Blah-Blah-Blah" );
Level 6: action must be taken immediately
log_emerg, log_emergency
$logger->log_emerg( <FORMAT>, <VALUE>, ... );
$logger->log_emerg( "Blah-Blah-Blah" );
Level 7: system is unusable
log_fatal
$logger->log_fatal( <FORMAT>, <VALUE>, ... );
$logger->log_fatal( "Blah-Blah-Blah" );
Level 8: fatal
log_except,log_exception
$logger->log_except( <FORMAT>, <VALUE>, ... );
$logger->log_except( "Blah-Blah-Blah" );
Level 9: exception
HISTORY
See Changes
file
DEPENDENCIES
TO DO
See TODO
file
BUGS
* none noted
SEE ALSO
AUTHOR
Serż Minus (Sergey Lepenkov) http://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2019 D&D Corporation. All Rights Reserved
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See LICENSE
file and https://dev.perl.org/licenses/