diff --git a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php index a897b91176f9653764e7336c8ab2a274a081ed98..68739ff92e329f6e8943e8cc3d6a8051066585db 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php @@ -14,13 +14,34 @@ require_once('SimpleSAML/Logger.php'); class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_LoggingHandler { + private $isWindows = false; + function __construct() { $config = SimpleSAML_Configuration::getInstance(); assert($config instanceof SimpleSAML_Configuration); - openlog("simpleSAMLphp", LOG_PID, $config->getValue('logging.facility') ); + $facility = $config->getValue('logging.facility'); + /* + * OS Check + * Setting facility to LOG_USER (only valid in Windows), enable log level rewrite on windows systems. + */ + if (substr(strtoupper(PHP_OS),0,3) == 'WIN') { + $this->isWindows = true; + $facility = LOG_USER; + } + + openlog("simpleSAMLphp", LOG_PID, $facility); } function log_internal($level,$string) { + /* + * Changing log level to supported levels if OS is Windows + */ + if ($this->isWindows) { + if ($level <= 4) + $level = LOG_ERR; + else + $level = LOG_INFO; + } syslog($level,$level.' '.$string); } }