diff --git a/core/logx/config.go b/core/logx/config.go index 2d75549c6..7d1a4c1e0 100644 --- a/core/logx/config.go +++ b/core/logx/config.go @@ -9,7 +9,7 @@ type LogConf struct { Path string `json:",default=logs"` Level string `json:",default=info,options=[debug,info,error,severe]"` Compress bool `json:",optional"` - DisableStat bool `json:",optional"` + Stat bool `json:",default=true"` KeepDays int `json:",optional"` StackCooldownMillis int `json:",default=100"` // MaxBackups represents how many backup log files will be kept. 0 means all files will be kept forever. diff --git a/core/logx/logs.go b/core/logx/logs.go index 07f200e94..65047d490 100644 --- a/core/logx/logs.go +++ b/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. setupOnce.Do(func() { setupLogLevel(c) - - if (c.DisableStat){ - DisableStat() + + if !c.Stat { + DisableStat() } - + if len(c.TimeFormat) > 0 { timeFormat = c.TimeFormat } diff --git a/core/logx/logs_test.go b/core/logx/logs_test.go index 415f9d42d..e8068a780 100644 --- a/core/logx/logs_test.go +++ b/core/logx/logs_test.go @@ -794,11 +794,7 @@ func testSetLevelTwiceWithMode(t *testing.T, mode string, w *mockWriter) { Mode: mode, Level: "error", Path: "/dev/null", - }) - SetUp(LogConf{ - Mode: mode, - Level: "info", - Path: "/dev/null", + Stat: false, }) const message = "hello there" Info(message)