From dd9facac9728f9bca710f8c745a2b3ec14c066a6 Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Fri, 26 Feb 2016 11:05:03 +0100 Subject: [PATCH] Move the SimpleSAML_Logger class to SimpleSAML\Logger. --- lib/SimpleSAML/Logger.php | 22 ++++++++++++---------- lib/SimpleSAML/Metadata/SAMLParser.php | 6 +++--- lib/_autoload_modules.php | 2 +- www/_include.php | 4 ++-- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index f505a4339..07a6fc494 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -1,5 +1,7 @@ <?php +namespace SimpleSAML; + /** * The main logger class for SimpleSAMLphp. @@ -10,11 +12,11 @@ * @package SimpleSAMLphp * @version $ID$ */ -class SimpleSAML_Logger +class Logger { /** - * @var SimpleSAML_Logger_LoggingHandler|false|null + * @var \SimpleSAML_Logger_LoggingHandler|false|null */ private static $loggingHandler = null; @@ -264,7 +266,7 @@ class SimpleSAML_Logger */ public static function flush() { - $s = SimpleSAML_Session::getSessionFromRequest(); + $s = \SimpleSAML_Session::getSessionFromRequest(); self::$trackid = $s->getTrackID(); self::$shuttingDown = true; @@ -333,7 +335,7 @@ class SimpleSAML_Logger // register a shutdown handler if needed if (!self::$shutdownRegistered) { - register_shutdown_function(array('SimpleSAML_Logger', 'flush')); + register_shutdown_function(array('SimpleSAML\Logger', 'flush')); self::$shutdownRegistered = true; } } @@ -344,8 +346,8 @@ class SimpleSAML_Logger self::$loggingHandler = false; // get the configuration - $config = SimpleSAML_Configuration::getInstance(); - assert($config instanceof SimpleSAML_Configuration); + $config = \SimpleSAML_Configuration::getInstance(); + assert($config instanceof \SimpleSAML_Configuration); // get the metadata handler option from the configuration $handler = $config->getString('logging.handler', 'syslog'); @@ -356,13 +358,13 @@ class SimpleSAML_Logger $handler = strtolower($handler); if ($handler === 'syslog') { - $sh = new SimpleSAML_Logger_LoggingHandlerSyslog(); + $sh = new \SimpleSAML_Logger_LoggingHandlerSyslog(); } elseif ($handler === 'file') { - $sh = new SimpleSAML_Logger_LoggingHandlerFile(); + $sh = new \SimpleSAML_Logger_LoggingHandlerFile(); } elseif ($handler === 'errorlog') { - $sh = new SimpleSAML_Logger_LoggingHandlerErrorLog(); + $sh = new \SimpleSAML_Logger_LoggingHandlerErrorLog(); } else { - throw new Exception( + throw new \Exception( 'Invalid value for the [logging.handler] configuration option. Unknown handler: '.$handler ); } diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php index 82b912db4..02e6e91c4 100644 --- a/lib/SimpleSAML/Metadata/SAMLParser.php +++ b/lib/SimpleSAML/Metadata/SAMLParser.php @@ -1042,7 +1042,7 @@ class SimpleSAML_Metadata_SAMLParser // Registration Authority cannot be overridden (warn only if override attempts to change the value) if (isset($ret['RegistrationInfo']['registrationAuthority']) && $ret['RegistrationInfo']['registrationAuthority'] !== $e->registrationAuthority) { - SimpleSAML_Logger::warning('Invalid attempt to override registrationAuthority \'' + SimpleSAML\Logger::warning('Invalid attempt to override registrationAuthority \'' . $ret['RegistrationInfo']['registrationAuthority'] . "' with '{$e->registrationAuthority}'"); } else { $ret['RegistrationInfo']['registrationAuthority'] = $e->registrationAuthority; @@ -1465,7 +1465,7 @@ class SimpleSAML_Metadata_SAMLParser } } } - SimpleSAML_Logger::debug('Could not validate signature'); + SimpleSAML\Logger::debug('Could not validate signature'); return false; } @@ -1496,7 +1496,7 @@ class SimpleSAML_Metadata_SAMLParser } } } - SimpleSAML_Logger::debug('Fingerprint was ['.$fingerprint.'] not one of ['.join(', ', $candidates).']'); + SimpleSAML\Logger::debug('Fingerprint was ['.$fingerprint.'] not one of ['.join(', ', $candidates).']'); return false; } } diff --git a/lib/_autoload_modules.php b/lib/_autoload_modules.php index 71cebf8ec..e17c187dd 100644 --- a/lib/_autoload_modules.php +++ b/lib/_autoload_modules.php @@ -26,7 +26,7 @@ function temporaryLoader($class) $path = explode('_', $class); $new = join('\\', $path); if (class_exists($new, false)) { - SimpleSAML_Logger::warning("The class '$class' is now using namespaces, please use '$new'."); + SimpleSAML\Logger::warning("The class '$class' is now using namespaces, please use '$new'."); class_alias($new, $class); } diff --git a/www/_include.php b/www/_include.php index 875559d1d..f587766c7 100644 --- a/www/_include.php +++ b/www/_include.php @@ -50,7 +50,7 @@ set_exception_handler('SimpleSAML_exception_handler'); // log full backtrace on errors and warnings function SimpleSAML_error_handler($errno, $errstr, $errfile = null, $errline = 0, $errcontext = null) { - if (!class_exists('SimpleSAML_Logger')) { + if (!class_exists('SimpleSAML\Logger')) { /* We are probably logging a deprecation-warning during parsing. Unfortunately, the autoloader is disabled at * this point, so we should stop here. * @@ -59,7 +59,7 @@ function SimpleSAML_error_handler($errno, $errstr, $errfile = null, $errline = 0 return false; } - if (SimpleSAML_Logger::isErrorMasked($errno)) { + if (SimpleSAML\Logger::isErrorMasked($errno)) { // masked error return false; } -- GitLab