mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Optimization for log
This commit is contained in:
parent
f4f6ea681e
commit
9f7cc1ae69
@ -36,7 +36,6 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
ws.sendErrMsg(conn, 201, err.Error(), m.ReqIdentifier, m.MsgIncr, m.OperationID)
|
||||
return
|
||||
}
|
||||
|
||||
log.NewInfo(m.OperationID, "Basic Info Authentication Success", m.SendID, m.MsgIncr, m.ReqIdentifier)
|
||||
|
||||
switch m.ReqIdentifier {
|
||||
@ -57,10 +56,12 @@ func (ws *WServer) msgParse(conn *UserConn, binaryMsg []byte) {
|
||||
}
|
||||
log.NewInfo(m.OperationID, "goroutine num is ", runtime.NumGoroutine())
|
||||
}
|
||||
|
||||
func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
log.NewInfo(m.OperationID, "Ws call success to getNewSeq", m.MsgIncr, m.SendID, m.ReqIdentifier)
|
||||
nReply := new(sdk_ws.GetMaxAndMinSeqResp)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSGetNewestSeq)
|
||||
isPass, errCode, errMsg, data := ws.argsValidate(m, constant.WSGetNewestSeq, m.OperationID)
|
||||
log.Info(m.OperationID, "argsValidate ", isPass, errCode, errMsg)
|
||||
if isPass {
|
||||
rpcReq := sdk_ws.GetMaxAndMinSeqReq{}
|
||||
rpcReq.GroupIDList = data.(sdk_ws.GetMaxAndMinSeqReq).GroupIDList
|
||||
@ -71,9 +72,9 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
msgClient := pbChat.NewChatClient(grpcConn)
|
||||
rpcReply, err := msgClient.GetMaxAndMinSeq(context.Background(), &rpcReq)
|
||||
if err != nil {
|
||||
log.Error(rpcReq.OperationID, "rpc call failed to getSeqReq", err.Error(), rpcReq.String())
|
||||
nReply.ErrCode = 500
|
||||
nReply.ErrMsg = err.Error()
|
||||
log.Error(rpcReq.OperationID, "rpc call failed to GetMaxAndMinSeq ", nReply.String())
|
||||
ws.getSeqResp(conn, m, nReply)
|
||||
} else {
|
||||
log.NewInfo(rpcReq.OperationID, "rpc call success to getSeqReq", rpcReply.String())
|
||||
@ -82,6 +83,7 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
||||
} else {
|
||||
nReply.ErrCode = errCode
|
||||
nReply.ErrMsg = errMsg
|
||||
log.Error(m.OperationID, "argsValidate failed send resp: ", nReply.String())
|
||||
ws.getSeqResp(conn, m, nReply)
|
||||
}
|
||||
}
|
||||
|
@ -57,16 +57,16 @@ type SeqListData struct {
|
||||
SeqList []int64 `mapstructure:"seqList" validate:"required"`
|
||||
}
|
||||
|
||||
func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, errMsg string, returnData interface{}) {
|
||||
func (ws *WServer) argsValidate(m *Req, r int32, operationID string) (isPass bool, errCode int32, errMsg string, returnData interface{}) {
|
||||
switch r {
|
||||
case constant.WSGetNewestSeq:
|
||||
data := open_im_sdk.GetMaxAndMinSeqReq{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
log.Error("", "Decode Data struct err", err.Error(), r)
|
||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
||||
return false, 203, err.Error(), nil
|
||||
}
|
||||
if err := validate.Struct(data); err != nil {
|
||||
log.Error("", "data args validate err", err.Error(), r)
|
||||
log.Error(operationID, "data args validate err", err.Error(), r)
|
||||
return false, 204, err.Error(), nil
|
||||
|
||||
}
|
||||
@ -74,11 +74,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
|
||||
case constant.WSSendMsg:
|
||||
data := open_im_sdk.MsgData{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
log.Error("", "Decode Data struct err", err.Error(), r)
|
||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
||||
return false, 203, err.Error(), nil
|
||||
}
|
||||
if err := validate.Struct(data); err != nil {
|
||||
log.Error("", "data args validate err", err.Error(), r)
|
||||
log.Error(operationID, "data args validate err", err.Error(), r)
|
||||
return false, 204, err.Error(), nil
|
||||
|
||||
}
|
||||
@ -86,11 +86,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
|
||||
case constant.WSSendSignalMsg:
|
||||
data := pbRtc.SignalReq{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
log.Error("", "Decode Data struct err", err.Error(), r)
|
||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
||||
return false, 203, err.Error(), nil
|
||||
}
|
||||
if err := validate.Struct(data); err != nil {
|
||||
log.Error("", "data args validate err", err.Error(), r)
|
||||
log.Error(operationID, "data args validate err", err.Error(), r)
|
||||
return false, 204, err.Error(), nil
|
||||
|
||||
}
|
||||
@ -98,31 +98,16 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
|
||||
case constant.WSPullMsgBySeqList:
|
||||
data := open_im_sdk.PullMessageBySeqListReq{}
|
||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||
log.Error("", "Decode Data struct err", err.Error(), r)
|
||||
log.Error(operationID, "Decode Data struct err", err.Error(), r)
|
||||
return false, 203, err.Error(), nil
|
||||
}
|
||||
if err := validate.Struct(data); err != nil {
|
||||
log.Error("", "data args validate err", err.Error(), r)
|
||||
log.Error(operationID, "data args validate err", err.Error(), r)
|
||||
return false, 204, err.Error(), nil
|
||||
|
||||
}
|
||||
return true, 0, "", data
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
return false, 204, "args err", nil
|
||||
|
||||
//b := bytes.NewBuffer(m.Data)
|
||||
//dec := gob.NewDecoder(b)
|
||||
//err := dec.Decode(&data)
|
||||
//if err != nil {
|
||||
// log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||
// return false, 203, err.Error(), nil
|
||||
//}
|
||||
//if err := mapstructure.WeakDecode(m.Data, &data); err != nil {
|
||||
// log.ErrorByKv("map to Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
||||
// return false, 203, err.Error(), nil
|
||||
//} else
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user