diff --git a/config-templates/config.php b/config-templates/config.php index 3b6399696a3152b8fa8ddf1c6839db795ee0475d..d6578f049a5b8433008e9f8425582f65d2e36fff 100644 --- a/config-templates/config.php +++ b/config-templates/config.php @@ -89,7 +89,7 @@ $config = array ( */ 'logging.level' => LOG_NOTICE, 'logging.handler' => 'syslog', - + 'logging.processname' => 'simpleSAMLphp', /* Logging: syslog - Choose a syslog facility to use for logging. */ 'logging.facility' => LOG_LOCAL5, diff --git a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php index 5ae9ec220a585b1775a0b29679a0188c669bc801..0a9bddbff31233b1ad8770d9290d614c75a55d7a 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php @@ -23,17 +23,21 @@ class SimpleSAML_Logger_LoggingHandlerErrorLog implements SimpleSAML_Logger_Logg LOG_NOTICE => 'NOTICE', LOG_INFO => 'INFO', LOG_DEBUG => 'DEBUG', - ); + ); - function log_internal($level, $string) { + function log_internal($level, $string) { + $config = SimpleSAML_Configuration::getInstance(); + assert($config instanceof SimpleSAML_Configuration); + $processname = $config->getValue('logging.processname','simpleSAMLphp'); + if(array_key_exists($level, self::$levelNames)) { $levelName = self::$levelNames[$level]; } else { $levelName = sprintf('UNKNOWN%d', $level); } - error_log($levelName . ': ' . $string); + error_log($processname.' - '.$levelName . ': ' . $string); } } diff --git a/lib/SimpleSAML/Logger/LoggingHandlerFile.php b/lib/SimpleSAML/Logger/LoggingHandlerFile.php index c9e0b2828057d842a4b8e277c5847848a4376e4b..d14381038a8806b8d3924df9641b4719df6f9c4b 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerFile.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerFile.php @@ -11,7 +11,8 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingHandler { - private $logFile = null; + private $logFile = null; + private $processname = null; function __construct() { $config = SimpleSAML_Configuration::getInstance(); @@ -19,7 +20,8 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH /* Get the metadata handler option from the configuration. */ $this->logFile = $config->getPathValue('loggingdir').$config->getValue('logging.logfile'); - + $this->processname = $config->getValue('logging.processname','simpleSAMLphp'); + if (@file_exists($this->logFile)) { if (!@is_writeable($this->logFile)) throw new Exception("Could not write to logfile: ".$this->logFile); } @@ -31,7 +33,7 @@ class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingH function log_internal($level,$string) { if ($this->logFile != null) { - $line = sprintf("%s ssp %d %s\n",strftime("%b %d %H:%M:%S"),$level,$string); + $line = sprintf("%s %s %d %s\n",strftime("%b %d %H:%M:%S"),$this->processname,$level,$string); file_put_contents($this->logFile,$line,FILE_APPEND); } } diff --git a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php index 86789ee24319516a9f2376671697b08cdb59425f..9d92f979df06c1918461ed864bc9179df19cc482 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php @@ -16,7 +16,8 @@ class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_Loggin function __construct() { $config = SimpleSAML_Configuration::getInstance(); assert($config instanceof SimpleSAML_Configuration); - $facility = $config->getValue('logging.facility'); + $facility = $config->getValue('logging.facility'); + $processname = $config->getValue('logging.processname','simpleSAMLphp'); /* * OS Check * Setting facility to LOG_USER (only valid in Windows), enable log level rewrite on windows systems. @@ -26,7 +27,7 @@ class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_Loggin $facility = LOG_USER; } - openlog("simpleSAMLphp", LOG_PID, $facility); + openlog($processname, LOG_PID, $facility); } function log_internal($level,$string) {