From 26c63ead48d3485234713b0ff35853e6298d9271 Mon Sep 17 00:00:00 2001 From: kanade Date: Mon, 7 Aug 2023 17:38:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logger.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/logger.go b/logger.go index 40693b0..a5c307a 100644 --- a/logger.go +++ b/logger.go @@ -42,7 +42,8 @@ var ( type logger struct { *zap.Logger - Config *LoggerConfig + Config *LoggerConfig + hasShowLine bool } type LoggerConfig struct { @@ -161,7 +162,8 @@ func (l *logger) getWriteSyncer(filename string) (zapcore.WriteSyncer, error) { path.Join(l.Config.Director, filename+".%Y-%m-%d.log"), options..., ) - if l.Config.LogInConsole { + if l.Config.LogInConsole && !l.hasShowLine { + l.hasShowLine = true return zapcore.NewMultiWriteSyncer(zapcore.AddSync(os.Stdout), zapcore.AddSync(fileWriter)), err } return zapcore.AddSync(fileWriter), err