Skip to content

Commit

Permalink
feat: add log enable config
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Jun 9, 2022
1 parent cd21f14 commit 5b73b68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bootstrap/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5b73b68

Please sign in to comment.