diff --git a/cmd/root.go b/cmd/root.go index 201d2d3..c1f8df9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -133,15 +133,19 @@ func initLog() { rotatelogs.WithMaxAge(60*24*time.Hour), rotatelogs.WithRotationTime(time.Hour)) - priority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool { + filePriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool { return lvl >= zapcore.DebugLevel }) + stdoutPriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool { + return lvl >= zapcore.InfoLevel + }) + encoder := zapcore.NewConsoleEncoder(zap.NewDevelopmentEncoderConfig()) core := zapcore.NewTee( - zapcore.NewCore(encoder, zapcore.Lock(os.Stdout), priority), - zapcore.NewCore(encoder, zapcore.AddSync(rotator), priority), + zapcore.NewCore(encoder, zapcore.Lock(os.Stdout), stdoutPriority), + zapcore.NewCore(encoder, zapcore.AddSync(rotator), filePriority), ) logger = zap.New(core)