Пример #1
0
 /**
  * @name customLog
  * @desc 记录自定义日志,请注意日志文件大小问题
  * @param string $filename 记录日志的文件名
  * @param string $msg    错误信息
  * @param int $priority  接受的类型
  * LOG_EMERG system is unusable
  * LOG_ALERT action must be taken immediately
  * LOG_CRIT critical conditions
  * LOG_ERR error conditions
  * LOG_WARNING warning conditions
  * LOG_NOTICE normal, but significant, condition
  * LOG_INFO informational message
  * LOG_DEBUG debug-level message
  */
 public static function customLog($filename, $msg, $priority = '')
 {
     $log_obj = LOG::getInstance();
     $string = "";
     $string .= "/*********************** " . $priority . " " . date('Y-m-d H:i:s') . " ***********************/\r\n";
     $string .= $msg . "\r\n";
     $fp = fopen($log_obj->path . DIRECTORY_SEPARATOR . $filename, 'a');
     flock($fp, LOCK_EX);
     fwrite($fp, $string);
     flock($fp, LOCK_UN);
     fclose($fp);
     return true;
 }