add some comments and one change that may fix effectiveLevel use

This commit is contained in:
Isaac Connor committed 2017-07-05 15:25:01 -04:00
1 parent 7ecce473f6
commit 2cab6baf2c
1 file changed
+15 -6
+15 -6
View File
@@ -293,24 +293,28 @@ sub terminate {
sub reinitialise {
my $this = shift;
# So if the logger is initialized, we just return. Since the logger is NORMALLY initialized... the rest of this function never executes.
return unless ( $this->{initialised} );
# Bit of a nasty hack to reopen connections to log files and the DB
my $syslogLevel = $this->syslogLevel();
$this->syslogLevel( NOLOG );
$this->syslogLevel( $syslogLevel ) if ( $syslogLevel > NOLOG );
my $logfileLevel = $this->fileLevel();
$this->fileLevel( NOLOG );
$this->fileLevel( $logfileLevel ) if ( $logfileLevel > NOLOG );
my $databaseLevel = $this->databaseLevel();
$this->databaseLevel( NOLOG );
$this->databaseLevel( $databaseLevel ) if ( $databaseLevel > NOLOG );
my $screenLevel = $this->termLevel();
$this->termLevel( NOLOG );
$this->syslogLevel( $syslogLevel ) if ( $syslogLevel > NOLOG );
$this->fileLevel( $logfileLevel ) if ( $logfileLevel > NOLOG );
$this->databaseLevel( $databaseLevel ) if ( $databaseLevel > NOLOG );
$this->databaseLevel( $databaseLevel ) if ( $databaseLevel > NOLOG );
$this->termLevel( $screenLevel ) if ( $screenLevel > NOLOG );
}
# Prevents undefined logging levels
sub limit {
my $this = shift;
my $level = shift;
@@ -371,12 +375,16 @@ sub level {
my $level = shift;
if ( defined($level) ) {
$this->{level} = $this->limit( $level );
# effectiveLevel is the highest logging level used by any of the outputs.
$this->{effectiveLevel} = NOLOG;
$this->{effectiveLevel} = $this->{termLevel} if ( $this->{termLevel} > $this->{effectiveLevel} );
$this->{effectiveLevel} = $this->{databaseLevel} if ( $this->{databaseLevel} > $this->{effectiveLevel} );
$this->{effectiveLevel} = $this->{fileLevel} if ( $this->{fileLevel} > $this->{effectiveLevel} );
$this->{effectiveLevel} = $this->{syslogLevel} if ( $this->{syslogLevel} > $this->{effectiveLevel} );
$this->{effectiveLevel} = $this->{level} if ( $this->{effectiveLevel} > $this->{effectiveLevel} );
# ICON: I am remarking this out because I don't see the point of having an effective level, if we are just going to set it to level.
#$this->{effectiveLevel} = $this->{level} if ( $this->{level} > $this->{effectiveLevel} );
}
return( $this->{level} );
}
@@ -396,6 +404,7 @@ sub termLevel {
my $this = shift;
my $termLevel = shift;
if ( defined($termLevel) ) {
# What is the point of this next lint if we are just going to overwrite it with the next line? I propose we move it down one line or remove it altogether
$termLevel = NOLOG if ( !$this->{hasTerm} );
$termLevel = $this->limit( $termLevel );
if ( $this->{termLevel} != $termLevel ) {