diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php index b7d84e9168c46be306826ed659d79231640c9be5..ea20881c0f170db9d7510adc1a971a2910dd8e2a 100644 --- a/lib/SimpleSAML/Logger.php +++ b/lib/SimpleSAML/Logger.php @@ -1,19 +1,35 @@ <?php + /** * The main logger class for SimpleSAMLphp. * * @author Lasse Birnbaum Jensen, SDU. * @author Andreas Ă…kre Solberg, UNINETT AS. <andreas.solberg@uninett.no> - * @package simpleSAMLphp + * @package SimpleSAMLphp * @version $ID$ */ - class SimpleSAML_Logger { - private static $loggingHandler = NULL; - private static $logLevel = NULL; - private static $captureLog = FALSE; + + /** + * @var SimpleSAML_Logger_LoggingHandler|false|null + */ + private static $loggingHandler = null; + + /** + * @var integer|null + */ + private static $logLevel = null; + + /** + * @var boolean + */ + private static $captureLog = false; + + /** + * @var array + */ private static $capturedLog = array(); /** @@ -34,7 +50,7 @@ class SimpleSAML_Logger * This variable holds the track ID we have retrieved from the session class. It can also be NULL, in which case * we haven't fetched the track ID yet, or TRACKID_FETCHING, which means that we are fetching the track ID now. */ - private static $trackid = NULL; + private static $trackid = null; /** * This variable holds the format used to log any message. Its use varies depending on the log handler used (for @@ -129,6 +145,7 @@ class SimpleSAML_Logger self::log(self::WARNING, $string); } + /** * We reserve the notice level for statistics, so do not use this level for other kind of log messages. * @@ -170,7 +187,7 @@ class SimpleSAML_Logger */ public static function stats($string) { - self::log(self::NOTICE, $string, TRUE); + self::log(self::NOTICE, $string, true); } @@ -179,7 +196,7 @@ class SimpleSAML_Logger * * @var boolean $val Whether to capture logs or not. Defaults to TRUE. */ - public static function setCaptureLog($val = TRUE) + public static function setCaptureLog($val = true) { self::$captureLog = $val; } @@ -197,7 +214,7 @@ class SimpleSAML_Logger private static function createLoggingHandler() { // set to FALSE to indicate that it is being initialized - self::$loggingHandler = FALSE; + self::$loggingHandler = false; // get the configuration $config = SimpleSAML_Configuration::getInstance(); @@ -219,7 +236,7 @@ class SimpleSAML_Logger $sh = new SimpleSAML_Logger_LoggingHandlerErrorLog(); } else { throw new Exception( - 'Invalid value for the [logging.handler] configuration option. Unknown handler: ' . $handler + 'Invalid value for the [logging.handler] configuration option. Unknown handler: '.$handler ); } @@ -231,14 +248,14 @@ class SimpleSAML_Logger } - private static function log($level, $string, $statsLog = FALSE) + private static function log($level, $string, $statsLog = false) { if (php_sapi_name() === 'cli' || defined('STDIN')) { // we are being executed from the CLI, nowhere to log return; } - if (self::$loggingHandler === NULL) { + if (self::$loggingHandler === null) { /* Initialize logging. */ self::createLoggingHandler(); @@ -249,7 +266,7 @@ class SimpleSAML_Logger self::log($msg['level'], $msg['string'], $msg['statsLog']); } } - } elseif (self::$loggingHandler === FALSE) { + } elseif (self::$loggingHandler === false) { // some error occurred while initializing logging if (empty(self::$earlyLog)) { // this is the first message @@ -262,7 +279,7 @@ class SimpleSAML_Logger } if (self::$captureLog) { - $ts = microtime(TRUE); + $ts = microtime(true); $msecs = (int) (($ts - (int) $ts) * 1000); $ts = GMdate('H:i:s', $ts).sprintf('.%03d', $msecs).'Z'; self::$capturedLog[] = $ts.' '.$string; @@ -301,7 +318,7 @@ class SimpleSAML_Logger return 'NA'; } - if (self::$trackid === NULL) { + if (self::$trackid === null) { // no track ID yet, fetch it from the session class // mark it as currently being fetched