diff --git a/modules/chat/module.go b/modules/chat/module.go index 0cb723dee..03ced0fa3 100644 --- a/modules/chat/module.go +++ b/modules/chat/module.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" "go_dreamfactory/lego/sys/event" + "go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/utils/codec/json" "go_dreamfactory/modules" "go_dreamfactory/pb" @@ -74,8 +75,9 @@ func (this *Chat) OnInstallComp() { //Event------------------------------------------------------------------------------------------------------------ func (this *Chat) EventUserOffline(session comm.IUserSession) { - err := this.modelChat.RemoveCrossChannelMember(session) - this.Debugf("EventUserOffline:%s err:%v", session, err) + if err := this.modelChat.RemoveCrossChannelMember(session); err != nil { + this.Debug("EventUserOffline:", log.Field{"uid", session.GetUserId()}, log.Field{"err", err}) + } } //对外接口---------------------------------------------------------------------------------------------------------- diff --git a/modules/rtask/module.go b/modules/rtask/module.go index 09cf773b2..f81979804 100644 --- a/modules/rtask/module.go +++ b/modules/rtask/module.go @@ -195,12 +195,11 @@ func (this *ModuleRtask) initRtaskVerifyHandle() { } func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.TaskType, params ...int32) (code pb.ErrorCode) { - this.Debugf("receive Rtask %v params: %v", rtaskType, params) + this.Debug("任务事件触发", log.Field{"uid", session.GetUserId()}, log.Field{"taskType", rtaskType}, log.Field{"params", params}) var ( err error condiId int32 - // condi *rtaskCondi - condis []*rtaskCondi + condis []*rtaskCondi ) user := this.ModuleUser.GetUser(session.GetUserId()) @@ -210,18 +209,24 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T } for _, codi := range this.configure.getRtaskCondis(int32(rtaskType)) { - if v, ok := this.handleMap[codi.Id]; ok { - if v.find == nil { - return - } - if condiId, err = v.find(v.cfg, params...); condiId == 0 { - if err != nil { - this.Error(err.Error()) - } - } else { - condis = append(condis, v) - } + v, ok := this.handleMap[codi.Id] + if !ok { + this.Warn("未注册事件处理器", log.Field{"uid", session.GetUserId()}, log.Field{"condiId", codi.Id}) + code = pb.ErrorCode_RtaskCondiNoFound + return } + + if v.find == nil { + return + } + if condiId, err = v.find(v.cfg, params...); condiId == 0 { + if err != nil { + this.Error(err.Error()) + } + } else { + condis = append(condis, v) + } + } // update @@ -233,7 +238,6 @@ func (this *ModuleRtask) SendToRtask(session comm.IUserSession, rtaskType comm.T code = pb.ErrorCode_DBError } } - } }