zou.yingbin 4 лет назад
Родитель
Сommit
7ee8633e13
2 измененных файлов с 6 добавлено и 1 удалено
  1. 1 1
      controllers/common/error.go
  2. 5 0
      controllers/other/logfileview.go

+ 1 - 1
controllers/common/error.go

@@ -44,6 +44,6 @@ func QueryErrorInfos(c *gin.Context) {
 	}
 
 	// 查询成功
-	logger.GetLogger().Debugln("QueryErrorInfos successed: %v", errorCodes)
+	//logger.GetLogger().Debugln("QueryErrorInfos successed: %v", errorCodes)
 	appG.Response(http.StatusOK, e.SUCCESS, errorCodes)
 }

+ 5 - 0
controllers/other/logfileview.go

@@ -56,7 +56,11 @@ func getFileContent(filename string, nLines int) string {
 	if err != nil {
 		return "file not found"
 	}
+	// bufio.Scan默认缓冲区大小只有40000, 如果不设置缓存区, 遇到数据大于40000的将返回false
+	const maxCapacity = 512 * 1024
+	buf := make([]byte, maxCapacity)
 	scanner := bufio.NewScanner(file)
+	scanner.Buffer(buf, maxCapacity)
 	total := 0
 	for scanner.Scan() {
 		total++
@@ -69,6 +73,7 @@ func getFileContent(filename string, nLines int) string {
 	file.Seek(0, 0)
 	index := 0
 	s := bufio.NewScanner(file)
+	s.Buffer(buf, maxCapacity)
 	for s.Scan() {
 		if index >= readPos {
 			txt += s.Text() + "<br>"