瀏覽代碼

use stat instead of disableStat (#2740)

Xargin 2 年之前
父節點
當前提交
1c544a26be
共有 3 個文件被更改,包括 6 次插入10 次删除
  1. 1 1
      core/logx/config.go
  2. 4 4
      core/logx/logs.go
  3. 1 5
      core/logx/logs_test.go

+ 1 - 1
core/logx/config.go

@@ -9,7 +9,7 @@ type LogConf struct {
 	Path                string `json:",default=logs"`
 	Path                string `json:",default=logs"`
 	Level               string `json:",default=info,options=[debug,info,error,severe]"`
 	Level               string `json:",default=info,options=[debug,info,error,severe]"`
 	Compress            bool   `json:",optional"`
 	Compress            bool   `json:",optional"`
-	DisableStat         bool   `json:",optional"`
+	Stat                bool   `json:",default=true"`
 	KeepDays            int    `json:",optional"`
 	KeepDays            int    `json:",optional"`
 	StackCooldownMillis int    `json:",default=100"`
 	StackCooldownMillis int    `json:",default=100"`
 	// MaxBackups represents how many backup log files will be kept. 0 means all files will be kept forever.
 	// MaxBackups represents how many backup log files will be kept. 0 means all files will be kept forever.

+ 4 - 4
core/logx/logs.go

@@ -229,11 +229,11 @@ func SetUp(c LogConf) (err error) {
 	// Need to wait for the first caller to complete the execution.
 	// Need to wait for the first caller to complete the execution.
 	setupOnce.Do(func() {
 	setupOnce.Do(func() {
 		setupLogLevel(c)
 		setupLogLevel(c)
-		
-        if (c.DisableStat){
-		   DisableStat()
+
+		if !c.Stat {
+			DisableStat()
 		}
 		}
-		
+
 		if len(c.TimeFormat) > 0 {
 		if len(c.TimeFormat) > 0 {
 			timeFormat = c.TimeFormat
 			timeFormat = c.TimeFormat
 		}
 		}

+ 1 - 5
core/logx/logs_test.go

@@ -794,11 +794,7 @@ func testSetLevelTwiceWithMode(t *testing.T, mode string, w *mockWriter) {
 		Mode:  mode,
 		Mode:  mode,
 		Level: "error",
 		Level: "error",
 		Path:  "/dev/null",
 		Path:  "/dev/null",
-	})
-	SetUp(LogConf{
-		Mode:  mode,
-		Level: "info",
-		Path:  "/dev/null",
+		Stat:  false,
 	})
 	})
 	const message = "hello there"
 	const message = "hello there"
 	Info(message)
 	Info(message)