From 5ecfd0396c569189651d5e7e091a5de8489e2e75 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Thu, 11 Dec 2025 20:27:10 +0000 Subject: [PATCH] =?UTF-8?q?```feat(log):=20=E4=BC=98=E5=8C=96=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=B7=BB=E5=8A=A0=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E6=97=A5=E5=BF=97=E6=A0=87=E5=BF=97=E5=B9=B6=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2socket=E6=9C=8D=E5=8A=A1=E4=B8=AD=E7=9A=84=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E8=BE=93=E5=87=BA=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/cool/global.go | 2 +- common/socket/ServerEvent.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/common/cool/global.go b/common/cool/global.go index 78dba6bab..6497a7d94 100644 --- a/common/cool/global.go +++ b/common/cool/global.go @@ -37,7 +37,7 @@ var DefaultGenerator = utils.NewGen(time.Date(2025, 1, 1, 0, 0, 0, 0, time.UTC), func init() { // 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId: - Loger.SetFlags(glog.F_TIME_STD | glog.F_FILE_LONG) //设置flag + Loger.SetFlags(glog.F_TIME_STD | glog.F_FILE_LONG | glog.F_ASYNC) //设置flag Loger.Print(ctx, "初始化日志") // for i := 0; i < 600; i++ { // glog.Debug(context.Background(), i, "初始化雪花算法", DefaultGenerator.Get()) diff --git a/common/socket/ServerEvent.go b/common/socket/ServerEvent.go index 07dc76347..f8506adf9 100644 --- a/common/socket/ServerEvent.go +++ b/common/socket/ServerEvent.go @@ -11,6 +11,8 @@ import ( "blazing/cool" "blazing/logic/service/player" + "github.com/gogf/gf/v2/os/glog" + "github.com/gogf/gf/v2/os/gtime" "github.com/panjf2000/gnet/v2" ) @@ -75,7 +77,7 @@ func (s *Server) OnClose(c gnet.Conn, err error) (action gnet.Action) { return } func (s *Server) OnTick() (delay time.Duration, action gnet.Action) { - cool.Loger.Infof(context.Background(), "[connected-count=%v]", atomic.LoadInt64(&s.connected)) + glog.Infof(context.Background(), gtime.Now().ISO8601(), "[connected-count=%v]", atomic.LoadInt64(&s.connected)) if s.quit && atomic.LoadInt64(&s.connected) == 0 { //执行正常退出逻辑 os.Exit(0)