Fix: std log set logrus std log writer

pull/21/head
zijiren233 2 years ago
parent 2dbe1b11c5
commit de1ce940b4

@ -38,12 +38,12 @@ func InitLog(ctx context.Context) error {
} }
var w io.Writer = colorable.NewNonColorableWriter(l) var w io.Writer = colorable.NewNonColorableWriter(l)
if flags.Dev || flags.LogStd { if flags.Dev || flags.LogStd {
w = io.MultiWriter(os.Stdout, w) logrus.SetOutput(io.MultiWriter(os.Stdout, w))
logrus.Infof("log: enable log to stdout and file: %s", conf.Conf.Log.FilePath) logrus.Infof("log: enable log to stdout and file: %s", conf.Conf.Log.FilePath)
} else { } else {
logrus.SetOutput(w)
logrus.Infof("log: disable log to stdout, only log to file: %s", conf.Conf.Log.FilePath) logrus.Infof("log: disable log to stdout, only log to file: %s", conf.Conf.Log.FilePath)
} }
logrus.SetOutput(w)
} }
switch conf.Conf.Log.LogFormat { switch conf.Conf.Log.LogFormat {
case "json": case "json":
@ -60,7 +60,7 @@ func InitLog(ctx context.Context) error {
logrus.SetFormatter(&logrus.TextFormatter{}) logrus.SetFormatter(&logrus.TextFormatter{})
} }
} }
log.SetOutput(logrus.StandardLogger().Out) log.SetOutput(logrus.StandardLogger().Writer())
return nil return nil
} }

Loading…
Cancel
Save