summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/SimpleSAML/Logger.php118
-rw-r--r--lib/SimpleSAML/Logger/LoggingHandlerFile.php9
-rw-r--r--lib/SimpleSAML/Logger/LoggingHandlerSyslog.php9
-rw-r--r--lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php14
-rw-r--r--lib/SimpleSAML/Session.php8
-rw-r--r--lib/SimpleSAML/Utilities.php2
-rw-r--r--lib/SimpleSAML/XHTML/Template.php6
7 files changed, 104 insertions, 62 deletions
diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php
index 7468fe1..2a2cdb8 100644
--- a/lib/SimpleSAML/Logger.php
+++ b/lib/SimpleSAML/Logger.php
@@ -6,64 +6,30 @@ require_once('SimpleSAML/Session.php');
/**
* A class for logging
*
+ * @author Lasse Birnbaum Jensen, SDU.
* @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
* @package simpleSAMLphp
* @version $ID$
*/
-class SimpleSAML_Logger {
-
-
- private $configuration = null;
- private $loglevel = LOG_NOTICE;
-
- public function __construct() {
-
- $this->configuration = SimpleSAML_Configuration::getInstance();
- $this->loglevel = $this->configuration->getValue('logging.level');
-
- define_syslog_variables();
- openlog("simpleSAMLphp", LOG_PID, $this->configuration->getValue('logging.facility') );
-
- }
-
- /*
- * Log a message to syslog.
- */
- public function log($priority, $trackid = null, $module, $submodule, $eventtype, $content, $message) {
- /*
- error_log('This entry: ' . $message );
- error_log('This entry is ' . $priority . ' and will be loged if <= ' . $this->loglevel);
- error_log('LOG_ERR is ' . LOG_ERR . ' and LOGINFO is ' . LOG_INFO . " LOG_DEBUG is " . LOG_DEBUG);
- */
- if ($priority > $this->loglevel) return;
- if ($trackid == null) {
- $trackid = 'na';
- //$session = SimpleSAML_Session::getInstance(true);
- //$trackid = $session->getTrackID();
- }
-
- $contentstring = '';
- if (is_array($content)) {
- $contentstring = implode('|', $content);
- } else {
- $contentstring = $content;
- }
-
- $logstring = implode(',', array($priority, $trackid, $module, $submodule, $eventtype, $contentstring, $message));
- syslog($priority, " OLD ".$logstring);
-
- }
-}
interface SimpleSAML_Logger_LoggingHandler {
function log_internal($level,$string);
}
-class Logger {
+class SimpleSAML_Logger {
private static $loggingHandler = null;
private static $logLevel = null;
private static $trackid = null;
+/*
+ * LOG_ERR No statistics, only errors
+ * LOG_WARNING No statistics, only warnings/errors
+ * LOG_NOTICE Statistics and errors
+ * LOG_INFO Verbose logs
+ * LOG_DEBUG Full debug logs - not reccomended for production
+
+*/
+
static function emergency($string) {
self::log_internal(LOG_EMERG,$string);
}
@@ -84,21 +50,39 @@ class Logger {
self::log_internal(LOG_WARNING,$string);
}
+ /**
+ * We reserve the notice level for statistics, so do not use
+ * this level for other kind of log messages.
+ */
static function notice($string) {
self::log_internal(LOG_NOTICE,$string);
}
+ /**
+ * Info messages is abit less verbose than debug messages. This is useful
+ * for tracing a session.
+ */
static function info($string) {
self::log_internal(LOG_INFO,$string);
}
-
+
+ /**
+ * Debug messages is very verbose, and will contain more inforation than
+ * what is neccessary for a production system.
+ */
static function debug($string) {
self::log_internal(LOG_DEBUG,$string);
}
+ /**
+ * Statisitics
+ */
static function stats($string) {
- self::log_internal(LOG_INFO,$string,true);
+ self::log_internal(LOG_NOTICE,$string,true);
}
+
+
+
public static function createLoggingHandler() {
/* Get the configuration. */
$config = SimpleSAML_Configuration::getInstance();
@@ -158,6 +142,46 @@ class Logger {
self::$loggingHandler->log_internal($level,$string);
}
}
+
+}
+
+
+ /*
+class SimpleSAML_Logger {
+
+
+ private $configuration = null;
+ private $loglevel = LOG_NOTICE;
+
+ public function __construct() {
+
+ $this->configuration = SimpleSAML_Configuration::getInstance();
+ $this->loglevel = $this->configuration->getValue('logging.level');
+
+ define_syslog_variables();
+ openlog("simpleSAMLphp", LOG_PID, $this->configuration->getValue('logging.facility') );
+
+ }
+ public function log($priority, $trackid = null, $module, $submodule, $eventtype, $content, $message) {
+
+ if ($priority > $this->loglevel) return;
+ if ($trackid == null) {
+ $trackid = 'na';
+ }
+
+ $contentstring = '';
+ if (is_array($content)) {
+ $contentstring = implode('|', $content);
+ } else {
+ $contentstring = $content;
+ }
+
+ $logstring = implode(',', array($priority, $trackid, $module, $submodule, $eventtype, $contentstring, $message));
+ syslog($priority, " OLD ".$logstring);
+
+ }
}
+*/
+
?> \ No newline at end of file
diff --git a/lib/SimpleSAML/Logger/LoggingHandlerFile.php b/lib/SimpleSAML/Logger/LoggingHandlerFile.php
index dd77cd6..b0239ef 100644
--- a/lib/SimpleSAML/Logger/LoggingHandlerFile.php
+++ b/lib/SimpleSAML/Logger/LoggingHandlerFile.php
@@ -3,6 +3,15 @@
require_once('SimpleSAML/Configuration.php');
require_once('SimpleSAML/Logger.php');
+/**
+ * A class for logging
+ *
+ * @author Lasse Birnbaum Jensen, SDU.
+ * @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
+ * @package simpleSAMLphp
+ * @version $ID$
+ */
+
class SimpleSAML_Logger_LoggingHandlerFile implements SimpleSAML_Logger_LoggingHandler {
private $logFile = null;
diff --git a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php
index 4ad3130..a897b91 100644
--- a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php
+++ b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php
@@ -3,6 +3,15 @@
require_once('SimpleSAML/Configuration.php');
require_once('SimpleSAML/Logger.php');
+/**
+ * A class for logging
+ *
+ * @author Lasse Birnbaum Jensen, SDU.
+ * @author Andreas Åkre Solberg, UNINETT AS. <andreas.solberg@uninett.no>
+ * @package simpleSAMLphp
+ * @version $ID$
+ */
+
class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_LoggingHandler {
function __construct() {
diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php
index 22eab31..3e45a82 100644
--- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php
+++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSAML2Meta.php
@@ -102,7 +102,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Met
$metadata = $this->loadFile($metadatasetfile);
}
- Logger::info('MetaData - Handler.SAML2Meta: Loading metadata set [' . $set . '] from [' . $metadatasetfile . ']' );
+ SimpleSAML_Logger::info('MetaData - Handler.SAML2Meta: Loading metadata set [' . $set . '] from [' . $metadatasetfile . ']' );
if (!is_array($metadata))
throw new Exception('Could not load metadata set [' . $set . '] from file: ' . $metadatasetfile);
@@ -178,7 +178,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Met
} catch (Exception $e) {
- Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
+ SimpleSAML_Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
}
}
@@ -215,7 +215,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Met
$metadata[$entityid]['ForceAuthn'] = (isset($seek_forceauth) ? ($seek_forceauth === 'true') : false);
} catch (Exception $e) {
- Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
+ SimpleSAML_Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
}
}
@@ -260,7 +260,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Met
$metadata[$entityid]['requireconsent'] = (isset($seek_requireconsent) ? ($seek_requireconsent === 'true') : false);
} catch (Exception $e) {
- Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
+ SimpleSAML_Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
}
}
@@ -325,7 +325,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Met
} catch (Exception $e) {
- Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
+ SimpleSAML_Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
}
}
@@ -371,7 +371,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Met
} catch (Exception $e) {
- Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
+ SimpleSAML_Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
}
}
@@ -455,7 +455,7 @@ class SimpleSAML_Metadata_MetaDataStorageHandlerSAML2Meta extends SimpleSAML_Met
} catch (Exception $e) {
- Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
+ SimpleSAML_Logger::info('MetaData - Handler.SAML2Meta: Error parsing [' . __FUNCTION__ . '] ' . $e->getMessage() );
}
}
diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index 7bc1092..7ce74f9 100644
--- a/lib/SimpleSAML/Session.php
+++ b/lib/SimpleSAML/Session.php
@@ -218,7 +218,7 @@ class SimpleSAML_Session {
public function getAuthnRequest($protocol, $requestid) {
- Logger::debug('Library - Session: Get authnrequest from cache ' . $protocol . ' time:' . time() . ' id: '. $requestid );
+ SimpleSAML_Logger::debug('Library - Session: Get authnrequest from cache ' . $protocol . ' time:' . time() . ' id: '. $requestid );
$configuration = SimpleSAML_Configuration::getInstance();
if (isset($this->authnrequests[$protocol])) {
@@ -231,7 +231,7 @@ class SimpleSAML_Session {
* simply delete it :)
*/
if ($cache['date'] < time() - $configuration->getValue('session.requestcache', 4*(60*60)) ) {
- Logger::debug('Library - Session: Deleting expired authn request with id ' . $id);
+ SimpleSAML_Logger::debug('Library - Session: Deleting expired authn request with id ' . $id);
unset($this->authnrequests[$protocol][$id]);
}
}
@@ -258,7 +258,7 @@ class SimpleSAML_Session {
*/
public function setAuthnRequest($protocol, $requestid, array $cache) {
- Logger::debug('Library - Session: Set authnrequest ' . $protocol . ' time:' . time() . ' size:' . count($cache) . ' id: '. $requestid );
+ SimpleSAML_Logger::debug('Library - Session: Set authnrequest ' . $protocol . ' time:' . time() . ' size:' . count($cache) . ' id: '. $requestid );
$this->dirty = true;
$cache['date'] = time();
@@ -375,7 +375,7 @@ class SimpleSAML_Session {
*/
public function clean($cleancache = false) {
- Logger::debug('Library - Session: Cleaning Session. Clean cache: ' . ($cleancache ? 'yes' : 'no') );
+ SimpleSAML_Logger::debug('Library - Session: Cleaning Session. Clean cache: ' . ($cleancache ? 'yes' : 'no') );
if ($cleancache) {
$this->authnrequests = array();
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 0553695..ac6d1a2 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -287,7 +287,7 @@ class SimpleSAML_Utilities {
$etrace = (empty($e) ? 'No exception available' : $e->getTraceAsString());
// Log a error message
- Logger::error($_SERVER['PHP_SELF'].' - UserError: ErrCode:'.(!empty($errorcode) ? $errorcode : 'na').': '.urlencode($emsg) );
+ SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - UserError: ErrCode:'.(!empty($errorcode) ? $errorcode : 'na').': '.urlencode($emsg) );
$languagefile = null;
if (isset($errorcode)) $languagefile = 'error_' . $errorcode . '.php';
diff --git a/lib/SimpleSAML/XHTML/Template.php b/lib/SimpleSAML/XHTML/Template.php
index e09f99a..2ccc135 100644
--- a/lib/SimpleSAML/XHTML/Template.php
+++ b/lib/SimpleSAML/XHTML/Template.php
@@ -85,7 +85,7 @@ class SimpleSAML_XHTML_Template {
if (!file_exists($filebase . $file) ) {
- Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . ']');
+ SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . ']');
return;
}
}
@@ -97,7 +97,7 @@ class SimpleSAML_XHTML_Template {
$filebase = $this->configuration->getBaseDir() . $this->configuration->getValue('dictionarydir');
if (!file_exists($filebase . $file)) {
- Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filebase . $file . ']');
+ SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filebase . $file . ']');
return;
}
include($filebase . $file);
@@ -128,7 +128,7 @@ class SimpleSAML_XHTML_Template {
if (!file_exists($filename)) {
- Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . ']');
+ SimpleSAML_Logger::error($_SERVER['PHP_SELF'].' - Template: Could not find template file [' . $this->template . '] at [' . $filename . ']');
echo 'Fatal error: Could not find template file [' . $this->template . '] at [' . $filename . ']';
exit(0);