Skip to content
Snippets Groups Projects
Commit 38362eef authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

If we are invoked from the command line, log the messages to standard error,...

If we are invoked from the command line, log the messages to standard error, instead of ignoring them.
parent a0e7623b
No related branches found
No related tags found
No related merge requests found
...@@ -365,6 +365,8 @@ class Logger ...@@ -365,6 +365,8 @@ class Logger
$sh = new \SimpleSAML_Logger_LoggingHandlerFile(); $sh = new \SimpleSAML_Logger_LoggingHandlerFile();
} elseif ($handler === 'errorlog') { } elseif ($handler === 'errorlog') {
$sh = new \SimpleSAML_Logger_LoggingHandlerErrorLog(); $sh = new \SimpleSAML_Logger_LoggingHandlerErrorLog();
} elseif ($handler === 'stderr') {
$sh = new \SimpleSAML\Logger\StandardError();
} else { } else {
throw new \Exception( throw new \Exception(
'Invalid value for the [logging.handler] configuration option. Unknown handler: '.$handler 'Invalid value for the [logging.handler] configuration option. Unknown handler: '.$handler
...@@ -381,12 +383,17 @@ class Logger ...@@ -381,12 +383,17 @@ class Logger
private static function log($level, $string, $statsLog = false) private static function log($level, $string, $statsLog = false)
{ {
if (php_sapi_name() === 'cli' || defined('STDIN')) { if (self::$loggingHandler === false) {
// we are being executed from the CLI, nowhere to log // some error occurred while initializing logging
self::defer($level, $string, $statsLog);
return; return;
} } elseif (php_sapi_name() === 'cli' || defined('STDIN')) {
// we are being executed from the CLI, nowhere to log
if (self::$loggingHandler === null) { if (is_null(self::$loggingHandler)) {
self::createLoggingHandler('stderr');
}
$_SERVER['REMOTE_ADDR'] = "CLI";
} elseif (self::$loggingHandler === null) {
// Initialize logging // Initialize logging
self::createLoggingHandler(); self::createLoggingHandler();
...@@ -396,9 +403,6 @@ class Logger ...@@ -396,9 +403,6 @@ class Logger
self::log($msg['level'], $msg['string'], $msg['statsLog']); self::log($msg['level'], $msg['string'], $msg['statsLog']);
} }
} }
} elseif (self::$loggingHandler === false) {
self::defer($level, $string, $statsLog);
return;
} }
if (self::$captureLog) { if (self::$captureLog) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment