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() {
|
func Log() {
|
||||||
log.SetOutput(logrus.StandardLogger().Out)
|
|
||||||
setLog(logrus.StandardLogger())
|
setLog(logrus.StandardLogger())
|
||||||
setLog(utils.Log)
|
setLog(utils.Log)
|
||||||
logConfig := conf.Conf.Log
|
logConfig := conf.Conf.Log
|
||||||
if logConfig.Enable {
|
if logConfig.Enable {
|
||||||
mw := io.MultiWriter(os.Stdout, &lumberjack.Logger{
|
var w io.Writer = &lumberjack.Logger{
|
||||||
Filename: logConfig.Name,
|
Filename: logConfig.Name,
|
||||||
MaxSize: logConfig.MaxSize, // megabytes
|
MaxSize: logConfig.MaxSize, // megabytes
|
||||||
MaxBackups: logConfig.MaxBackups,
|
MaxBackups: logConfig.MaxBackups,
|
||||||
MaxAge: logConfig.MaxAge, //days
|
MaxAge: logConfig.MaxAge, //days
|
||||||
Compress: logConfig.Compress, // disabled by default
|
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...")
|
utils.Log.Infof("init logrus...")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user