public function __construct($filename)
 {
     parent::__construct($filename, 'xml');
 }
Beispiel #2
0
 /**
  * Retrieves log messages from logger to log route specific destination.
  * @param TLogger logger instance
  */
 public function collectLogs(TLogger $logger)
 {
     $logs = $logger->getLogs($this->getLevels(), $this->getCategories());
     if (!empty($logs)) {
         $this->processLogs($logs);
     }
 }
Beispiel #3
0
 public static function parseConfig($rawConfig)
 {
     // 文件模式日志配置格式化
     $result = array('name' => TLogger::getArrayValue($rawConfig, 'name', 'default', 'string'), 'isLogging' => TLogger::getArrayValue($rawConfig, 'isLogging', TLogger::$g_isLogging, 'boolean'), 'mode' => TLogger::LOG_MODE_FILE, 'level' => TLogger::getArrayValue($rawConfig, 'level', TLogger::LOG_LEVEL_DEBUG, 'integer'), 'basePath' => TLogger::getArrayValue($rawConfig, 'basePath', TLogger::$g_basePath, 'string'), 'frequency' => TLogger::getArrayValue($rawConfig, 'frequency', TLogger::LOG_FREQUENCY_NONE, 'integer'));
     // 判断记录等级是否合法
     if ($result['level'] > TLogger::LOG_LEVEL_DEBUG || $result['level'] < TLogger::LOG_LEVEL_FATAL) {
         throw new TLoggerException("({$result['name']}) config level set error");
     }
     // 判断记录日志切割是否合法
     if ($result['frequency'] > TLogger::LOG_FREQUENCY_MONTH || $result['frequency'] < TLogger::LOG_FREQUENCY_NONE) {
         throw new TLoggerException("({$result['name']}) config frequency set error");
     }
     // 初始化日志记录根目录
     $result['basePath'] = rtrim($result['basePath'], DIRECTORY_SEPARATOR);
     if (!is_dir($result['basePath'])) {
         if (!mkdir($result['basePath'], 0775, true)) {
             throw new TLoggerException("({$result['name']}) config create directory fail:" . $result['basePath']);
         }
     }
     return $result;
 }