示例#1
0
文件: CoreLog.php 项目: ErosZy/CSF
 public function __construct()
 {
     $logPath = CoreHelper::loadConfig("log_path", "config");
     $logFileExtension = CoreHelper::loadConfig("log_file_extension", "config");
     $logThreshold = CoreHelper::loadConfig("log_threshold", "config");
     $logDateFormat = CoreHelper::loadConfig("log_date_format", "config");
     $logFilePermissions = CoreHelper::loadConfig("log_file_permissions", "config");
     $this->_log_path = $logPath !== '' ? $logPath : APPPATH . 'logs/';
     $this->_file_ext = isset($logFileExtension) && $logFileExtension !== '' ? ltrim($logFileExtension, '.') : 'php';
     file_exists($this->_log_path) || mkdir($this->_log_path, 0755, true);
     if (!is_dir($this->_log_path) || !CoreHelper::isWriteable($this->_log_path)) {
         $this->_enabled = false;
     }
     if (is_numeric($logThreshold)) {
         $this->_threshold = (int) $logThreshold;
     } elseif (is_array($logThreshold)) {
         $this->_threshold = 0;
         $this->_threshold_array = array_flip($logThreshold);
     }
     if (!empty($logDateFormat)) {
         $this->_date_fmt = $logDateFormat;
     }
     if (!empty($logFilePermissions) && is_int($logFilePermissions)) {
         $this->_file_permissions = $logFilePermissions;
     }
 }