Subject: | OFF/ALL levels are inverted |
Date: | Sat, 15 Aug 2015 18:26:03 +0200 |
To: | "bug-Log-Log4perl [...] rt.cpan.org" <bug-log-log4perl [...] rt.cpan.org> |
From: | JusTiCe 8 <justice__8 [...] hotmail.com> |
In both L4P 1.44 (from a Debian testing) and 1.46 (downloaded from the CPAN), the following code:
# ALL set to 0, OFF to 2^31 - 1
# it may be the opposite !
# comment in module:
# log4j, for whatever reason, puts 0 as all and MAXINT as OFF.
# this seems less optimal, as more logging would imply a higher
# level. But oh well. Probably some brokenness that has persisted. :)
# OFF is "no log/never log" I guess whereas ALL is "always log this statement whatever log level defined"
use strict;
use warnings;
use Log::Log4perl;
use Log::Log4perl::Level;
my $l4pconf =
{
'log4perl.category.l4pissue' => 'WARN, LOGFILE',
'log4perl.appender.LOGFILE' => 'Log::Log4perl::Appender::File',
'log4perl.appender.LOGFILE.filename' => 'l4plevelissue.log',
'log4perl.appender.LOGFILE.mode' => 'write',
'log4perl.appender.LOGFILE.layout' => 'Log::Log4perl::Layout::PatternLayout',
'log4perl.appender.LOGFILE.layout.ConversionPattern' => '%d %p> %F{1}:%L %M - %m %n',
};
eval
{
Log::Log4perl->init_once ($l4pconf);
$Log::Log4perl::caller_depth++;
};
if ($@)
{
print STDERR "Log4Perl init error: $@\n";
}
my $logger = Log::Log4perl->get_logger('l4pissue');
print "log some messages...\n";
$logger->log ($DEBUG, "a debug message");
$logger->log ($INFO, "a info message");
$logger->log ($WARN, "a warn message");
$logger->log ($ERROR, "a error message");
$logger->log ($FATAL, "a fatal message");
print "log an OFF msg\n";
$logger->log ($OFF, "a OFF message, SHOULD NOT BE THERE");
# should not be logged, but it is !
print "log an ALL msg\n";
$logger->log ($ALL, "a ALL message, SHOULD BE ALWAYS THERE");
# should be logged but it's not !
exit 0;
produce log file:
2015/08/15 18:19:28 WARN> [undef]:[undef] main:: - a warn message
2015/08/15 18:19:28 ERROR> [undef]:[undef] main:: - a error message
2015/08/15 18:19:28 FATAL> [undef]:[undef] main:: - a fatal message
2015/08/15 18:19:28 OFF> [undef]:[undef] main:: - a OFF message, SHOULD NOT BE THERE
expected behaviour:
2015/08/15 18:19:28 WARN> [undef]:[undef] main:: - a warn message
2015/08/15 18:19:28 ERROR> [undef]:[undef] main:: - a error message
2015/08/15 18:19:28 FATAL> [undef]:[undef] main:: - a fatal message
2015/08/15 18:19:28 ALL> [undef]:[undef] main:: - a ALL message, SHOULD BE ALWAYS THERE