Skip to content
Snippets Groups Projects
Unverified Commit 040c3b98 authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo Committed by GitHub
Browse files

Fix some logic mistakes in the Logger class

The new `$initializing` property should signal that we are initializing the logging handler with a value of `true`, not the other way around. Also, it should only be set to `true` while we are actually initializing the logging handler.
parent 823f8ef8
No related branches found
No related tags found
No related merge requests found
...@@ -398,9 +398,6 @@ class Logger ...@@ -398,9 +398,6 @@ class Logger
register_shutdown_function([self::class, 'shutdown']); register_shutdown_function([self::class, 'shutdown']);
self::$shutdownRegistered = true; self::$shutdownRegistered = true;
} }
// Set initializing to true > all went well!
self::$initializing = true;
} }
...@@ -411,6 +408,8 @@ class Logger ...@@ -411,6 +408,8 @@ class Logger
*/ */
private static function createLoggingHandler($handler = null) private static function createLoggingHandler($handler = null)
{ {
self::$initializing = true;
// a set of known logging handlers // a set of known logging handlers
$known_handlers = [ $known_handlers = [
'syslog' => 'SimpleSAML\Logger\SyslogLoggingHandler', 'syslog' => 'SimpleSAML\Logger\SyslogLoggingHandler',
...@@ -450,6 +449,8 @@ class Logger ...@@ -450,6 +449,8 @@ class Logger
self::$format = $config->getString('logging.format', self::$format); self::$format = $config->getString('logging.format', self::$format);
self::$loggingHandler->setLogFormat(self::$format); self::$loggingHandler->setLogFormat(self::$format);
self::$initializing = false;
} }
...@@ -461,7 +462,7 @@ class Logger ...@@ -461,7 +462,7 @@ class Logger
*/ */
private static function log($level, $string, $statsLog = false) private static function log($level, $string, $statsLog = false)
{ {
if (self::$initializing === false) { if (self::$initializing) {
// some error occurred while initializing logging // some error occurred while initializing logging
self::defer($level, $string, $statsLog); self::defer($level, $string, $statsLog);
return; return;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment