From a4a40f0e7d3c1d547d9a1e1dd1417420e0637f16 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Tue, 23 May 2023 16:03:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97=E5=A0=86?= =?UTF-8?q?=E6=A0=88=E8=BE=93=E5=87=BA=E5=92=8C=E4=BB=BB=E5=8A=A1=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lego/sys/log/logger.go | 58 ++++++++++++++++++++-------------- modules/equipment/api_equip.go | 2 +- modules/items/module.go | 3 ++ modules/modulebase.go | 22 ------------- modules/task/model_task.go | 8 +++-- modules/user/model_expand.go | 2 +- 6 files changed, 44 insertions(+), 51 deletions(-) diff --git a/lego/sys/log/logger.go b/lego/sys/log/logger.go index 453141f28..2c27d4c53 100644 --- a/lego/sys/log/logger.go +++ b/lego/sys/log/logger.go @@ -82,32 +82,42 @@ func (this *Logger) Enabled(lvl Loglevel) bool { return this.level.Enabled(lvl) } func (this *Logger) Debug(msg string, args ...Field) { - this.Log(DebugLevel, msg, args...) -} -func (this *Logger) Info(msg string, args ...Field) { - this.Log(InfoLevel, msg, args...) -} -func (this *Logger) Print(msg string, args ...Field) { - this.Log(InfoLevel, msg, args...) -} -func (this *Logger) Warn(msg string, args ...Field) { - this.Log(WarnLevel, msg, args...) -} -func (this *Logger) Error(msg string, args ...Field) { - this.Log(ErrorLevel, msg, args...) -} -func (this *Logger) Panic(msg string, args ...Field) { - this.Log(PanicLevel, msg, args...) -} -func (this *Logger) Fatal(msg string, args ...Field) { - this.Log(FatalLevel, msg, args...) - os.Exit(1) -} -func (this *Logger) Log(level Loglevel, msg string, args ...Field) { - if this.level.Enabled(level) { - this.logWithFields(level, msg, args...) + if this.level.Enabled(DebugLevel) { + this.logWithFields(DebugLevel, msg, args...) } } +func (this *Logger) Info(msg string, args ...Field) { + if this.level.Enabled(InfoLevel) { + this.logWithFields(InfoLevel, msg, args...) + } +} +func (this *Logger) Print(msg string, args ...Field) { + if this.level.Enabled(InfoLevel) { + this.logWithFields(InfoLevel, msg, args...) + } +} +func (this *Logger) Warn(msg string, args ...Field) { + if this.level.Enabled(WarnLevel) { + this.logWithFields(WarnLevel, msg, args...) + } +} +func (this *Logger) Error(msg string, args ...Field) { + if this.level.Enabled(ErrorLevel) { + this.logWithFields(ErrorLevel, msg, args...) + } +} +func (this *Logger) Panic(msg string, args ...Field) { + if this.level.Enabled(PanicLevel) { + this.logWithFields(PanicLevel, msg, args...) + } +} +func (this *Logger) Fatal(msg string, args ...Field) { + if this.level.Enabled(FatalLevel) { + this.logWithFields(ErrorLevel, msg, args...) + } + os.Exit(1) +} + func (this *Logger) Debugf(format string, args ...interface{}) { this.Logf(DebugLevel, format, args...) } diff --git a/modules/equipment/api_equip.go b/modules/equipment/api_equip.go index 5f86b930f..0b8e4909d 100644 --- a/modules/equipment/api_equip.go +++ b/modules/equipment/api_equip.go @@ -167,7 +167,7 @@ func (this *apiComp) Equip(session comm.IUserSession, req *pb.EquipmentEquipReq) code = pb.ErrorCode_SystemError return } - tasks = append(tasks, comm.GettaskParam(comm.Rtype5, 1, equipNum, utils.ToInt32(hero.HeroID))) + tasks = append(tasks, comm.GettaskParam(comm.Rtype5, equipNum, utils.ToInt32(hero.HeroID))) // this.module.ModuleRtask.SendToRtask(session, comm.Rtype5, utils.ToInt32(hero.HeroID), equipNum) for k, v := range equipStr { tasks = append(tasks, comm.GettaskParam(comm.Rtype41, 1, utils.ToInt32(hero.HeroID), v, k)) diff --git a/modules/items/module.go b/modules/items/module.go index ae5880f34..5bae922f7 100644 --- a/modules/items/module.go +++ b/modules/items/module.go @@ -51,6 +51,9 @@ func (this *Items) Start() (err error) { } this.privilege = module.(comm.IPrivilege) event.RegisterGO(comm.EventUserOffline, this.EventUserOffline) + this.Error("日志测试1") + this.Errorf("日志测试2") + this.Errorln("日志测试3") return } diff --git a/modules/modulebase.go b/modules/modulebase.go index 42aebd144..2ec13f68a 100644 --- a/modules/modulebase.go +++ b/modules/modulebase.go @@ -609,28 +609,6 @@ func (this *ModuleBase) Panicln(args ...interface{}) { this.options.GetLog().Panicln(args...) } -func (this *ModuleBase) DebugWithField(msg string, fields ...log.Field) { - -} -func (this *ModuleBase) InfoWithField(msg string, fields ...log.Field) { - -} -func (this *ModuleBase) PrintWithField(msg string, fields ...log.Field) { - -} -func (this *ModuleBase) WarnWithField(msg string, fields ...log.Field) { - -} -func (this *ModuleBase) ErrorWithField(msg string, fields ...log.Field) { - -} -func (this *ModuleBase) FatalWithField(msg string, fields ...log.Field) { - -} -func (this *ModuleBase) PanicWithField(msg string, fields ...log.Field) { - -} - // 发放资源 func (this *ModuleBase) DispenseAtno(session comm.IUserSession, res []*cfg.Gameatn, bPush bool) (code pb.ErrorCode, atno []*pb.UserAtno) { var ( diff --git a/modules/task/model_task.go b/modules/task/model_task.go index a42bd5de7..3fbb7cdc9 100644 --- a/modules/task/model_task.go +++ b/modules/task/model_task.go @@ -278,9 +278,11 @@ func (this *ModelTask) initTask(uid string, taskTag comm.TaskTag) error { } } - if err := this.Change(uid, update); err != nil { - this.moduleTask.Errorf("initTask err %v", err) - return err + if len(update) > 0 { + if err := this.Change(uid, update); err != nil { + this.moduleTask.Errorf("initTask err %v", err) + return err + } } return nil } diff --git a/modules/user/model_expand.go b/modules/user/model_expand.go index 0dc3c2626..54350780f 100644 --- a/modules/user/model_expand.go +++ b/modules/user/model_expand.go @@ -65,7 +65,7 @@ func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err ) return } - this.module.Error("Get", log.Field{Key: "uid", Value: uid}) + // this.module.Error("Get", log.Field{Key: "uid", Value: uid}) return result, err } }