mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
log change
This commit is contained in:
parent
6e226b165c
commit
2b479319c1
@ -62,7 +62,6 @@ func SendMsg(c *gin.Context) {
|
|||||||
params := paramsUserSendMsg{}
|
params := paramsUserSendMsg{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
log.ErrorByKv("json unmarshal err", "", "err", err.Error(), "data", c.PostForm("data"))
|
|
||||||
log.Error("0", "BindJSON failed ", err.Error())
|
log.Error("0", "BindJSON failed ", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
params := ManagementSendMsgReq{}
|
params := ManagementSendMsgReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": err.Error()})
|
||||||
log.ErrorByKv("json unmarshal err", c.PostForm("operationID"), "err", err.Error(), "content", c.PostForm("content"))
|
log.Error(c.PostForm("operationID"), "json unmarshal err", err.Error(), c.PostForm("content"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch params.ContentType {
|
switch params.ContentType {
|
||||||
@ -126,16 +126,16 @@ func ManagementSendMsg(c *gin.Context) {
|
|||||||
//case constant.Quote:
|
//case constant.Quote:
|
||||||
default:
|
default:
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 404, "errMsg": "contentType err"})
|
||||||
log.ErrorByKv("contentType err", c.PostForm("operationID"), "content", c.PostForm("content"))
|
log.Error(c.PostForm("operationID"), "contentType err", c.PostForm("content"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
if err := mapstructure.WeakDecode(params.Content, &data); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 401, "errMsg": err.Error()})
|
||||||
log.ErrorByKv("content to Data struct err", "", "err", err.Error())
|
log.Error(c.PostForm("operationID"), "content to Data struct err", err.Error())
|
||||||
return
|
return
|
||||||
} else if err := validate.Struct(data); err != nil {
|
} else if err := validate.Struct(data); err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
c.JSON(http.StatusBadRequest, gin.H{"errCode": 403, "errMsg": err.Error()})
|
||||||
log.ErrorByKv("data args validate err", "", "err", err.Error())
|
log.Error(c.PostForm("operationID"), "data args validate err", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.NewInfo("", data, params)
|
log.NewInfo("", data, params)
|
||||||
|
@ -77,7 +77,7 @@ func SendVerificationCode(c *gin.Context) {
|
|||||||
m.SetHeader(`Subject`, config.Config.Demo.Mail.Title)
|
m.SetHeader(`Subject`, config.Config.Demo.Mail.Title)
|
||||||
m.SetBody(`text/html`, fmt.Sprintf("%d", code))
|
m.SetBody(`text/html`, fmt.Sprintf("%d", code))
|
||||||
if err := gomail.NewDialer(config.Config.Demo.Mail.SmtpAddr, config.Config.Demo.Mail.SmtpPort, config.Config.Demo.Mail.SenderMail, config.Config.Demo.Mail.SenderAuthorizationCode).DialAndSend(m); err != nil {
|
if err := gomail.NewDialer(config.Config.Demo.Mail.SmtpAddr, config.Config.Demo.Mail.SmtpPort, config.Config.Demo.Mail.SenderMail, config.Config.Demo.Mail.SenderAuthorizationCode).DialAndSend(m); err != nil {
|
||||||
log.ErrorByKv("send mail error", account, "err", err.Error())
|
log.Error(params.OperationID, "send mail error", account, err.Error())
|
||||||
c.JSON(http.StatusOK, gin.H{"errCode": constant.MailSendCodeErr, "errMsg": ""})
|
c.JSON(http.StatusOK, gin.H{"errCode": constant.MailSendCodeErr, "errMsg": ""})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -69,9 +69,6 @@ func (ws *WServer) getSeqReq(conn *UserConn, m *Req) {
|
|||||||
rpcReq.UserID = m.SendID
|
rpcReq.UserID = m.SendID
|
||||||
rpcReq.OperationID = m.OperationID
|
rpcReq.OperationID = m.OperationID
|
||||||
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
grpcConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOfflineMessageName)
|
||||||
if grpcConn == nil {
|
|
||||||
log.ErrorByKv("get grpcConn err", rpcReq.OperationID, "args", m)
|
|
||||||
}
|
|
||||||
msgClient := pbChat.NewChatClient(grpcConn)
|
msgClient := pbChat.NewChatClient(grpcConn)
|
||||||
rpcReply, err := msgClient.GetMaxAndMinSeq(context.Background(), &rpcReq)
|
rpcReply, err := msgClient.GetMaxAndMinSeq(context.Background(), &rpcReq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -62,11 +62,11 @@ func (ws *WServer) argsValidate(m *Req, r int32) (isPass bool, errCode int32, er
|
|||||||
case constant.WSSendMsg:
|
case constant.WSSendMsg:
|
||||||
data := open_im_sdk.MsgData{}
|
data := open_im_sdk.MsgData{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
log.Error("", "Decode Data struct err", err.Error(), r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
}
|
}
|
||||||
if err := validate.Struct(data); err != nil {
|
if err := validate.Struct(data); err != nil {
|
||||||
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
|
log.Error("", "data args validate err", err.Error(), r)
|
||||||
return false, 204, err.Error(), nil
|
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.WSSendSignalMsg:
|
case constant.WSSendSignalMsg:
|
||||||
data := pbRtc.SignalReq{}
|
data := pbRtc.SignalReq{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
log.Error("", "Decode Data struct err", err.Error(), r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
}
|
}
|
||||||
if err := validate.Struct(data); err != nil {
|
if err := validate.Struct(data); err != nil {
|
||||||
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
|
log.Error("", "data args validate err", err.Error(), r)
|
||||||
return false, 204, err.Error(), nil
|
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.WSPullMsgBySeqList:
|
case constant.WSPullMsgBySeqList:
|
||||||
data := open_im_sdk.PullMessageBySeqListReq{}
|
data := open_im_sdk.PullMessageBySeqListReq{}
|
||||||
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
if err := proto.Unmarshal(m.Data, &data); err != nil {
|
||||||
log.ErrorByKv("Decode Data struct err", "", "err", err.Error(), "reqIdentifier", r)
|
log.Error("", "Decode Data struct err", err.Error(), r)
|
||||||
return false, 203, err.Error(), nil
|
return false, 203, err.Error(), nil
|
||||||
}
|
}
|
||||||
if err := validate.Struct(data); err != nil {
|
if err := validate.Struct(data); err != nil {
|
||||||
log.ErrorByKv("data args validate err", "", "err", err.Error(), "reqIdentifier", r)
|
log.Error("", "data args validate err", err.Error(), r)
|
||||||
return false, 204, err.Error(), nil
|
return false, 204, err.Error(), nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ func (ws *WServer) run() {
|
|||||||
http.HandleFunc("/", ws.wsHandler) //Get request from client to handle by wsHandler
|
http.HandleFunc("/", ws.wsHandler) //Get request from client to handle by wsHandler
|
||||||
err := http.ListenAndServe(ws.wsAddr, nil) //Start listening
|
err := http.ListenAndServe(ws.wsAddr, nil) //Start listening
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("Ws listening err", "", "err", err.Error())
|
panic("Ws listening err:" + err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ func (ws *WServer) wsHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
query := r.URL.Query()
|
query := r.URL.Query()
|
||||||
conn, err := ws.wsUpGrader.Upgrade(w, r, nil) //Conn is obtained through the upgraded escalator
|
conn, err := ws.wsUpGrader.Upgrade(w, r, nil) //Conn is obtained through the upgraded escalator
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("upgrade http conn err", "", "err", err, query)
|
log.Error("", "upgrade http conn err", err, query)
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
//Connection mapping relationship,
|
//Connection mapping relationship,
|
||||||
@ -77,7 +77,7 @@ func (ws *WServer) readMsg(conn *UserConn) {
|
|||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
uid, platform := ws.getUserUid(conn)
|
uid, platform := ws.getUserUid(conn)
|
||||||
log.ErrorByKv("WS ReadMsg error", "", "userIP", conn.RemoteAddr().String(), "userUid", uid, "platform", platform, "error", err.Error())
|
log.Error("", "WS ReadMsg error", "userIP", conn.RemoteAddr().String(), "userUid", uid, "platform", platform, "error", err.Error())
|
||||||
userCount--
|
userCount--
|
||||||
ws.delUserConn(conn)
|
ws.delUserConn(conn)
|
||||||
return
|
return
|
||||||
|
@ -34,7 +34,7 @@ func (ms *PushConsumerHandler) handleMs2PsChat(msg []byte) {
|
|||||||
log.NewDebug("", "msg come from kafka And push!!!", "msg", string(msg))
|
log.NewDebug("", "msg come from kafka And push!!!", "msg", string(msg))
|
||||||
msgFromMQ := pbChat.PushMsgDataToMQ{}
|
msgFromMQ := pbChat.PushMsgDataToMQ{}
|
||||||
if err := proto.Unmarshal(msg, &msgFromMQ); err != nil {
|
if err := proto.Unmarshal(msg, &msgFromMQ); err != nil {
|
||||||
log.ErrorByKv("push Unmarshal msg err", "", "msg", string(msg), "err", err.Error())
|
log.Error("", "push Unmarshal msg err", "msg", string(msg), "err", err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//Call push module to send message to the user
|
//Call push module to send message to the user
|
||||||
|
@ -42,7 +42,7 @@ func (rpc *rpcChat) PullMessageBySeqList(_ context.Context, in *open_im_sdk.Pull
|
|||||||
//msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
|
//msgList, err := commonDB.DB.GetMsgBySeqList(in.UserID, in.SeqList, in.OperationID)
|
||||||
msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID)
|
msgList, err := commonDB.DB.GetMsgBySeqListMongo2(in.UserID, in.SeqList, in.OperationID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("PullMessageBySeqList data error", in.OperationID, in.String())
|
log.Error(in.OperationID, "PullMessageBySeqList data error", in.String(), err.Error())
|
||||||
resp.ErrCode = 201
|
resp.ErrCode = 201
|
||||||
resp.ErrMsg = err.Error()
|
resp.ErrMsg = err.Error()
|
||||||
return resp, nil
|
return resp, nil
|
||||||
|
@ -419,7 +419,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
|
|||||||
func (rpc *rpcChat) sendMsgToKafka(m *pbChat.MsgDataToMQ, key string) error {
|
func (rpc *rpcChat) sendMsgToKafka(m *pbChat.MsgDataToMQ, key string) error {
|
||||||
pid, offset, err := rpc.producer.SendMessage(m, key)
|
pid, offset, err := rpc.producer.SendMessage(m, key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ErrorByKv("kafka send failed", m.OperationID, "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key)
|
log.Error(m.OperationID, "kafka send failed", "send data", m.String(), "pid", pid, "offset", offset, "err", err.Error(), "key", key)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ type Statistics struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Statistics) output() {
|
func (s *Statistics) output() {
|
||||||
|
var intervalCount uint64
|
||||||
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
|
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
|
||||||
defer t.Stop()
|
defer t.Stop()
|
||||||
var sum uint64
|
var sum uint64
|
||||||
@ -21,7 +22,12 @@ func (s *Statistics) output() {
|
|||||||
select {
|
select {
|
||||||
case <-t.C:
|
case <-t.C:
|
||||||
}
|
}
|
||||||
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.AllCount-sum, "total:", *s.AllCount)
|
if *s.AllCount-sum <= 0 {
|
||||||
|
intervalCount = 0
|
||||||
|
} else {
|
||||||
|
intervalCount = *s.AllCount - sum
|
||||||
|
}
|
||||||
|
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, intervalCount, "total:", *s.AllCount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user