From 5b73b68eb58f7df1b6bff60d3caad4417039fd6c Mon Sep 17 00:00:00 2001 From: Noah Hsu Date: Thu, 9 Jun 2022 15:12:34 +0800 Subject: [PATCH] feat: add log enable config --- bootstrap/log.go | 2 +- conf/config.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/bootstrap/log.go b/bootstrap/log.go index 08a79e8f35d..c64e7353b0b 100644 --- a/bootstrap/log.go +++ b/bootstrap/log.go @@ -22,7 +22,7 @@ func Log() { FullTimestamp: true, }) logConfig := conf.Conf.Log - if !args.Debug && logConfig.Path != "" { + if logConfig.Enable { var ( writer *rotatelogs.RotateLogs err error diff --git a/conf/config.go b/conf/config.go index 01fabe9666a..cd276c314e1 100644 --- a/conf/config.go +++ b/conf/config.go @@ -24,6 +24,7 @@ type CacheConfig struct { } type LogConfig struct { + Enable bool `json:"enable" env:"log_enable"` Path string `json:"path" env:"LOG_PATH"` Name string `json:"name" env:"LOG_NAME"` RotationTime uint `json:"rotation_time" env:"LOG_TIME"` @@ -59,6 +60,7 @@ func DefaultConfig() *Config { CleanupInterval: 120, }, Log: LogConfig{ + Enable: true, Path: "log/%Y-%m-%d-%H:%M.log", Name: "log/log.log", RotationTime: 24,