Skip to content
Snippets Groups Projects
Commit 717e103b authored by Lasse Birnbaum Jensen's avatar Lasse Birnbaum Jensen
Browse files

Changed Logging Handler for Syslog.

Now compatible with logging on Windows servers (Eventlog). Solution done from suggestions. Windows server owners please verify this fix.  

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@316 44740490-163a-0410-bde0-09ae8108e29a
parent d3db15b7
No related branches found
No related tags found
No related merge requests found
...@@ -14,13 +14,34 @@ require_once('SimpleSAML/Logger.php'); ...@@ -14,13 +14,34 @@ require_once('SimpleSAML/Logger.php');
class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_LoggingHandler { class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_LoggingHandler {
private $isWindows = false;
function __construct() { function __construct() {
$config = SimpleSAML_Configuration::getInstance(); $config = SimpleSAML_Configuration::getInstance();
assert($config instanceof SimpleSAML_Configuration); 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) { 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); syslog($level,$level.' '.$string);
} }
} }
......
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