Esempio n. 1
0
 /**
  * @param integer $enableLogLevels bitmask of enabled log levels. By default all error levels will be enabled.
  *
  * @return bool
  * @example CTaskAssert::enableLogging(CTaskAssert::ELL_TRACE | CTaskAssert::ELL_DEBUG);
  */
 public static function enableLogging($enableLogLevels = null)
 {
     if (self::$sessId === false) {
         $tmp = '';
         for ($i = 0; $i < 4; $i++) {
             if (mt_rand(1, 36) <= 10) {
                 $tmp .= chr(mt_rand(48, 57));
             } else {
                 $tmp .= chr(mt_rand(65, 90));
             }
         }
         self::$sessId = $tmp;
         unset($tmp);
     }
     if (self::$fp === null && self::$pathToLogFile === false) {
         self::setLogFileName($_SERVER['DOCUMENT_ROOT'] . BX_ROOT . '/modules/tasks.log');
     }
     if (self::$fp === null) {
         AddMessage2Log('[ERROR] CTaskAssert::enableLogging(): Log file cannot be used or not set. Logging not enabled.', 'tasks');
         return false;
     }
     // if wrong error levels given, log this and switch to default value
     if ($enableLogLevels !== null && !is_int($enableLogLevels)) {
         $enableLogLevels = null;
         AddMessage2Log('[ERROR] CTaskAssert::enableLogging(): Invalid log errors level set, using defaults', 'tasks');
     }
     // If null given, than use default value (all levels enabled)
     if ($enableLogLevels === null) {
         $enableLogLevels = self::ELL_TRACE | self::ELL_DEBUG | self::ELL_INFO | self::ELL_WARNING | self::ELL_ERROR | self::ELL_FATAL;
     }
     self::$bmEnabledLogLevels = $enableLogLevels;
     if ($enableLogLevels !== 0) {
         self::$bLogEnabled = true;
     } else {
         self::$bLogEnabled = false;
     }
     return true;
 }