feat: only log to std on debug/dev mode
This commit is contained in:
parent
51f5d1b3c4
commit
44cb8aaafe
@ -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...")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user