getUtil('log')->write('日志内容'); * @param string $message 日志信息 * @param string $log_type 日志类型 ERROR WARN DEBUG INFO * @return */ public function write($message, $log_type = 'DEBUG') { $log_path = $this->get_file_log_name(); if(is_file($log_path) && ($this->default_file_size < filesize($log_path)) ) { rename($log_path, dirname($log_path).'/'.time().'-Bak-'.basename($log_path)); } $message = $this->get_message($message, $log_type); error_log($message, 3, $log_path, ''); } /** * 写日志-获取文件日志名称 * @return string */ private function get_file_log_name() { $config = InitPHP::getConfig(); return $config['log_dir'] . $this->_errorLogFileName(); } /** * 写日志-组装message信息 * @param string $message 日志信息 * @param string $log_type 日志类型 * @return string */ private function get_message($message, $log_type) { return date("Y-m-d H:i:s") . " [{$log_type}] : {$message}\r\n"; } /** * * @return string */ private function _errorLogFileName(){ return "initphp_log_" . date('Y-m-d').'.log'; } }