summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLasse Birnbaum Jensen <lasse@sdu.dk>2008-06-18 07:46:36 +0000
committerLasse Birnbaum Jensen <lasse@sdu.dk>2008-06-18 07:46:36 +0000
commit5832b4ded69c730cb47284235b4f4a06a30c0804 (patch)
tree67b1f67b8d9add470d1911f005baec5098ab2a1f
parent238ec6edaede848f12e37508c422948f8dfd5154 (diff)
downloadsimplesamlphp-5832b4ded69c730cb47284235b4f4a06a30c0804.zip
simplesamlphp-5832b4ded69c730cb47284235b4f4a06a30c0804.tar.gz
simplesamlphp-5832b4ded69c730cb47284235b4f4a06a30c0804.tar.bz2
Added options to configure processname for logging. Usefull when having multiple installations on the same machine.
Processname in the log is determined by the 'logging.processname' configuration key. It defaults to "simpleSAMLphp" if not set. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@667 44740490-163a-0410-bde0-09ae8108e29a
-rw-r--r--config-templates/config.php2
-rw-r--r--lib/SimpleSAML/Logger/LoggingHandlerErrorLog.php10
-rw-r--r--lib/SimpleSAML/Logger/LoggingHandlerFile.php8
-rw-r--r--lib/SimpleSAML/Logger/LoggingHandlerSyslog.php5
4 files changed, 16 insertions, 9 deletions
diff --git a/config-templates/config.php b/config-templates/config.php
index 3b63996..d6578f0 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 5ae9ec2..0a9bddb 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 c9e0b28..d143810 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 86789ee..9d92f97 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) {