From e167cce59e4cd0b164bf9fb9b468164e4a132aa8 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 8 Aug 2022 15:56:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=87=E4=BB=BD=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/log/logger.go | 6 ++++-- lego/sys/log/sys_test.go | 2 +- services/comp_gateroute.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lego/sys/log/logger.go b/lego/sys/log/logger.go index 50c527b92..207f8491f 100644 --- a/lego/sys/log/logger.go +++ b/lego/sys/log/logger.go @@ -17,8 +17,10 @@ func newSys(options *Options) (sys *Logger, err error) { MaxBackups: options.MaxBackups, //最大备份数 LocalTime: true, //使用本地时间 } - if err = hook.openNew(); err != nil { - return + if !options.IsDebug { + if err = hook.openNew(); err != nil { + return + } } out := make(writeTree, 0, 2) out = append(out, AddSync(&hook)) diff --git a/lego/sys/log/sys_test.go b/lego/sys/log/sys_test.go index a97e73db4..f759ff7a5 100644 --- a/lego/sys/log/sys_test.go +++ b/lego/sys/log/sys_test.go @@ -23,7 +23,7 @@ func TestMain(m *testing.M) { var err error if sys, err = log.NewSys( log.SetFileName("log.log"), - log.SetIsDebug(false), + log.SetIsDebug(true), log.SetEncoder(log.TextEncoder), ); err != nil { fmt.Println(err) diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index 4163ee59c..65892df7e 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -159,7 +159,7 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag log.Field{Key: "m", Value: method}, log.Field{Key: "uid", Value: args.UserId}, log.Field{Key: "req", Value: msg}, - log.Field{Key: "reply", Value: reply}, + log.Field{Key: "reply", Value: reply.String()}, ) } else { reply.Reply = session.Polls() @@ -170,7 +170,7 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag log.Field{Key: "m", Value: method}, log.Field{Key: "uid", Value: args.UserId}, log.Field{Key: "req", Value: msg}, - log.Field{Key: "reply", Value: reply}, + log.Field{Key: "reply", Value: reply.String()}, ) } } From fa554438c9fe9e7f95942d90c3cb345def26f758 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Mon, 8 Aug 2022 16:10:42 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E5=88=86=E5=89=B2=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/log/flieout.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lego/sys/log/flieout.go b/lego/sys/log/flieout.go index 9567e7145..a7be8dc66 100644 --- a/lego/sys/log/flieout.go +++ b/lego/sys/log/flieout.go @@ -92,7 +92,7 @@ func (l *LogFileOut) openExistingOrNew(writeLen int) error { } //校验是否需要切割日志 - if info.Size()+int64(writeLen) >= l.max() || time.Since(l.ctime) > l.CupTime { + if info.Size()+int64(writeLen) >= l.max() || (!l.ctime.IsZero() && time.Since(l.ctime) > l.CupTime) { return l.rotate() }