feat: add log enable config

refactor/fs
Noah Hsu 2022-06-09 15:12:34 +08:00
parent cd21f14106
commit 5b73b68eb5
2 changed files with 3 additions and 1 deletions

View File

@ -22,7 +22,7 @@ func Log() {
FullTimestamp: true, FullTimestamp: true,
}) })
logConfig := conf.Conf.Log logConfig := conf.Conf.Log
if !args.Debug && logConfig.Path != "" { if logConfig.Enable {
var ( var (
writer *rotatelogs.RotateLogs writer *rotatelogs.RotateLogs
err error err error

View File

@ -24,6 +24,7 @@ type CacheConfig struct {
} }
type LogConfig struct { type LogConfig struct {
Enable bool `json:"enable" env:"log_enable"`
Path string `json:"path" env:"LOG_PATH"` Path string `json:"path" env:"LOG_PATH"`
Name string `json:"name" env:"LOG_NAME"` Name string `json:"name" env:"LOG_NAME"`
RotationTime uint `json:"rotation_time" env:"LOG_TIME"` RotationTime uint `json:"rotation_time" env:"LOG_TIME"`
@ -59,6 +60,7 @@ func DefaultConfig() *Config {
CleanupInterval: 120, CleanupInterval: 120,
}, },
Log: LogConfig{ Log: LogConfig{
Enable: true,
Path: "log/%Y-%m-%d-%H:%M.log", Path: "log/%Y-%m-%d-%H:%M.log",
Name: "log/log.log", Name: "log/log.log",
RotationTime: 24, RotationTime: 24,