Bläddra i källkod

调试日志优化

zou.yingbin 4 år sedan
förälder
incheckning
ca379ea794
1 ändrade filer med 9 tillägg och 0 borttagningar
  1. 9 0
      controllers/other/logfileview.go

+ 9 - 0
controllers/other/logfileview.go

@@ -112,6 +112,9 @@ func getFileContent(filename string, nLines int) string {
 		index++
 	}
 
+	txt = setColorForSubString(txt, "FROM", "#DC143C")
+	txt = setColorForSubString(txt, "from", "#DC143C")
+
 	return txt
 }
 
@@ -119,3 +122,9 @@ func getFileContent(filename string, nLines int) string {
 func setFontColor(str string, clr string) string {
 	return fmt.Sprintf(`<font color="%v">%v</font>`, clr, str)
 }
+
+// 为某个子串设置颜色
+func setColorForSubString(str string, subStr string, clr string) string {
+	newStr := setFontColor(subStr, clr)
+	return strings.ReplaceAll(str, subStr, newStr)
+}