diff options
author | Jaime Perez Crespo <jaime.perez@uninett.no> | 2016-03-31 15:25:57 +0200 |
---|---|---|
committer | Jaime Perez Crespo <jaime.perez@uninett.no> | 2016-03-31 15:25:57 +0200 |
commit | 38362eef57500385e8817c122532b9a593e87dd5 (patch) | |
tree | 9c05f160ae37daa0b3baff6bda5cdd3d5efcc59f /lib/SimpleSAML | |
parent | a0e7623b6ad7139e4debe3721305d137877f49c1 (diff) | |
download | simplesamlphp-38362eef57500385e8817c122532b9a593e87dd5.zip simplesamlphp-38362eef57500385e8817c122532b9a593e87dd5.tar.gz simplesamlphp-38362eef57500385e8817c122532b9a593e87dd5.tar.bz2 |
If we are invoked from the command line, log the messages to standard error, instead of ignoring them.
Diffstat (limited to 'lib/SimpleSAML')
-rw-r--r-- | lib/SimpleSAML/Logger.php | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index 8801a4a..ef3127a 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -365,6 +365,8 @@ class Logger $sh = new \SimpleSAML_Logger_LoggingHandlerFile(); } elseif ($handler === 'errorlog') { $sh = new \SimpleSAML_Logger_LoggingHandlerErrorLog(); + } elseif ($handler === 'stderr') { + $sh = new \SimpleSAML\Logger\StandardError(); } else { throw new \Exception( 'Invalid value for the [logging.handler] configuration option. Unknown handler: '.$handler @@ -381,12 +383,17 @@ class Logger private static function log($level, $string, $statsLog = false) { - if (php_sapi_name() === 'cli' || defined('STDIN')) { - // we are being executed from the CLI, nowhere to log + if (self::$loggingHandler === false) { + // some error occurred while initializing logging + self::defer($level, $string, $statsLog); return; - } - - if (self::$loggingHandler === null) { + } elseif (php_sapi_name() === 'cli' || defined('STDIN')) { + // we are being executed from the CLI, nowhere to log + if (is_null(self::$loggingHandler)) { + self::createLoggingHandler('stderr'); + } + $_SERVER['REMOTE_ADDR'] = "CLI"; + } elseif (self::$loggingHandler === null) { // Initialize logging self::createLoggingHandler(); @@ -396,9 +403,6 @@ class Logger self::log($msg['level'], $msg['string'], $msg['statsLog']); } } - } elseif (self::$loggingHandler === false) { - self::defer($level, $string, $statsLog); - return; } if (self::$captureLog) { |