diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index 07c4df6f6..180122b01 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -112,16 +112,16 @@ func (this *SCompGateRoute) RegisterRoute(methodName string, comp reflect.Value, //Rpc_GatewayRoute服务接口的接收函数 func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessage, reply *pb.RPCMessageReply) (err error) { + method := fmt.Sprintf("%s.%s", args.MainType, args.SubType) defer func() { //程序异常 收集异常信息传递给前端显示 if r := recover(); r != nil { buf := make([]byte, 4096) l := runtime.Stack(buf, false) reply.Code = pb.ErrorCode_Exception reply.ErrorMessage = fmt.Sprintf("%v: %s", r, buf[:l]) - log.Errorf("[Handle Api]:[%s-%s] err:%s", args.MainType, args.SubType, reply.ErrorMessage) + log.Errorf("[Handle Api] m:%s reply:%s", method, reply) } }() - method := fmt.Sprintf("%s.%s", args.MainType, args.SubType) //获取用户消息处理函数 this.mrlock.RLock() msghandle, ok := this.msghandles[method] @@ -148,17 +148,17 @@ func (this *SCompGateRoute) ReceiveMsg(ctx context.Context, args *pb.AgentMessag errcode := pb.ErrorCode(handlereturn[0].Int()) errdata := handlereturn[1].Interface() if errcode != pb.ErrorCode_Success { //处理返货错误码 返回用户错误信息 - log.Errorf("[Handle Api] method:%s msg:%v code:%d", method, msg, errcode) reply.Code = errcode reply.ErrorMessage = pb.GetErrorCodeMsg(errcode) if errdata != nil { data, _ := anypb.New(errdata.(proto.Message)) reply.ErrorData = data } + log.Errorf("[Handle Api] t:%v m:%s req:%v reply:%v", time.Since(stime), method, msg, reply) } else { reply.Reply = session.Polls() if this.options.Debug { - log.Debugf("[Handle Api] consumetime:%v method:%s uid:%s msg:%v reply:%#v", time.Since(stime), method, args.UserId, msg, reply) + log.Debugf("[Handle Api] t:%v m:%s uid:%s req:%v reply:%v", time.Since(stime), method, args.UserId, msg, reply) } } } else { //未找到消息处理函数