From 2cab6baf2cb9c7da1cd0aa3a2f71fe86a855abc1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 5 Jul 2017 15:25:01 -0400 Subject: [PATCH] add some comments and one change that may fix effectiveLevel use --- scripts/ZoneMinder/lib/ZoneMinder/Logger.pm | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm index 44c7f7e8e..123033105 100644 --- a/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm +++ b/scripts/ZoneMinder/lib/ZoneMinder/Logger.pm @@ -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 ) {