Skip to content

Commit

Permalink
Item13063: Enable logging of "notice" level messages
Browse files Browse the repository at this point in the history
"notice" messages  (level 2)  will be directed to the Configure.log file
(named appropriately for the Compatibility or Plain file logger).

Still need to add the log calls for changes made by configure.
  • Loading branch information
gac410 committed Nov 6, 2014
1 parent d11ff62 commit be89cfd
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
31 changes: 16 additions & 15 deletions UnitTestContrib/test/unit/LoggerTests.pm
Expand Up @@ -21,6 +21,7 @@ sub set_up {
delete $Foswiki::cfg{LogFileName};
delete $Foswiki::cfg{DebugFileName};
delete $Foswiki::cfg{WarningFileName};
delete $Foswiki::cfg{ConfigureLogFileName};
$this->SUPER::set_up();
$logDir = "logDir$$";
$Foswiki::cfg{Log}{Dir} = "$logDir";
Expand Down Expand Up @@ -155,11 +156,12 @@ sub skip {
sub CompatibilityLogger {
my $this = shift;
require Foswiki::Logger::Compatibility;
$Foswiki::cfg{Log}{Implementation} = 'Foswiki::Logger::Compatibility';
$this->{logger} = Foswiki::Logger::Compatibility->new();
$Foswiki::cfg{LogFileName} = "$logDir/logfile%DATE%";
$Foswiki::cfg{DebugFileName} = "$logDir/debug%DATE%";
$Foswiki::cfg{WarningFileName} = "$logDir/warn%DATE%!!";
$Foswiki::cfg{Log}{Implementation} = 'Foswiki::Logger::Compatibility';
$this->{logger} = Foswiki::Logger::Compatibility->new();
$Foswiki::cfg{LogFileName} = "$logDir/logfile%DATE%";
$Foswiki::cfg{DebugFileName} = "$logDir/debug%DATE%";
$Foswiki::cfg{WarningFileName} = "$logDir/warn%DATE%!!";
$Foswiki::cfg{ConfigureLogFileName} = "$logDir/configure%DATE%!!";

return;
}
Expand Down Expand Up @@ -193,9 +195,10 @@ sub LogDispatchFileLogger {
$Foswiki::cfg{Log}{LogDispatch}{MaskIP} = 'none';
$Foswiki::cfg{Log}{LogDispatch}{Screen}{Enabled} = 1;
$Foswiki::cfg{Log}{LogDispatch}{File}{FileLevels} = {
'events' => 'info:info',
'error' => 'notice:emergency',
'debug' => 'debug:debug',
'events' => 'info:info',
'configure' => 'notice:notice',
'error' => 'warning:emergency',
'debug' => 'debug:debug',
};
$this->{logger} = Foswiki::Logger::LogDispatch->new();

Expand All @@ -211,9 +214,10 @@ sub LogDispatchFileObfuscatingLogger {
$Foswiki::cfg{Log}{LogDispatch}{MaskIP} = 'x.x.x.x';
$Foswiki::cfg{Log}{LogDispatch}{Screen}{Enabled} = 1;
$Foswiki::cfg{Log}{LogDispatch}{File}{FileLevels} = {
'events' => 'info:info',
'error' => 'notice:emergency',
'debug' => 'debug:debug',
'events' => 'info:info',
'configure' => 'notice:notice',
'error' => 'warning:emergency',
'debug' => 'debug:debug',
};
$this->{logger} = Foswiki::Logger::LogDispatch->new();

Expand Down Expand Up @@ -323,10 +327,7 @@ sub verify_eachEventSince_MultiLevelsV0 {
( $Foswiki::cfg{Log}{Implementation} eq
'Foswiki::Logger::PlainFile::Obfuscating' ) ? 'x.x.x.x' : '1.2.3.4';

my @levels =
( $Foswiki::cfg{Log}{Implementation} =~ /LogDispatch/ )
? qw(debug info notice warning error critical alert emergency)
: qw(debug info warning error critical alert emergency);
my @levels = qw(debug info notice warning error critical alert emergency);

my $testIP = $logIP;
my $it = $this->{logger}->eachEventSince( $time, \@levels );
Expand Down
4 changes: 4 additions & 0 deletions core/lib/Foswiki/Logger/Compatibility.pm
Expand Up @@ -270,6 +270,10 @@ sub _getLogsForLevel {
$log = $Foswiki::cfg{LogFileName}
|| $defaultLogDir . 'log%DATE%.txt';
}
elsif ( $lvl eq 'notice' ) {
$log = $Foswiki::cfg{ConfigureLogFileName}
|| $defaultLogDir . 'configure%DATE%.txt';
}
else {
ASSERT( $lvl =~ /^(warning|error|critical|alert|emergency)$/ )
if DEBUG;
Expand Down
8 changes: 5 additions & 3 deletions core/lib/Foswiki/Logger/PlainFile.pm
Expand Up @@ -69,6 +69,7 @@ use constant TRACE => 0;
our %LEVEL2LOG = (
debug => 'debug',
info => 'events',
notice => 'configure',
warning => 'error',
error => 'error',
critical => 'error',
Expand All @@ -77,9 +78,10 @@ our %LEVEL2LOG = (
);

our %nextCheckDue = (
debug => 0,
events => 0,
error => 0,
configure => 0,
debug => 0,
events => 0,
error => 0,
);

# Symbols used so we can override during unit testing
Expand Down

0 comments on commit be89cfd

Please sign in to comment.