Skip to content

Commit

Permalink
feat: only log to std on debug/dev mode
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Feb 5, 2023
1 parent 51f5d1b commit 44cb8aa
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions internal/bootstrap/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,22 @@ func setLog(l *logrus.Logger) {
}

func Log() {
log.SetOutput(logrus.StandardLogger().Out)
setLog(logrus.StandardLogger())
setLog(utils.Log)
logConfig := conf.Conf.Log
if logConfig.Enable {
mw := io.MultiWriter(os.Stdout, &lumberjack.Logger{
var w io.Writer = &lumberjack.Logger{
Filename: logConfig.Name,
MaxSize: logConfig.MaxSize, // megabytes
MaxBackups: logConfig.MaxBackups,
MaxAge: logConfig.MaxAge, //days
Compress: logConfig.Compress, // disabled by default
})
logrus.SetOutput(mw)
}
if flags.Debug || flags.Dev {
w = io.MultiWriter(os.Stdout, w)
}
logrus.SetOutput(w)
}
log.SetOutput(logrus.StandardLogger().Out)
utils.Log.Infof("init logrus...")
}

0 comments on commit 44cb8aa

Please sign in to comment.