mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-11-03 01:52:17 +08:00
feat: logs
This commit is contained in:
parent
7143444bd2
commit
9bc31f649e
@ -237,6 +237,7 @@ func (och *OnlineHistoryRedisConsumerHandler) categorizeMessageLists(totalMsgs [
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (och *OnlineHistoryRedisConsumerHandler) handleMsg(ctx context.Context, key, conversationID string, storageList, notStorageList []*ContextMsg) {
|
func (och *OnlineHistoryRedisConsumerHandler) handleMsg(ctx context.Context, key, conversationID string, storageList, notStorageList []*ContextMsg) {
|
||||||
|
log.ZInfo(ctx, "handle storage msg")
|
||||||
for _, storageMsg := range storageList {
|
for _, storageMsg := range storageList {
|
||||||
log.ZDebug(ctx, "handle storage msg", "msg", storageMsg.message.String())
|
log.ZDebug(ctx, "handle storage msg", "msg", storageMsg.message.String())
|
||||||
}
|
}
|
||||||
@ -253,6 +254,8 @@ func (och *OnlineHistoryRedisConsumerHandler) handleMsg(ctx context.Context, key
|
|||||||
log.ZError(ctx, "batch data insert to redis err", err, "storageMsgList", storageMessageList)
|
log.ZError(ctx, "batch data insert to redis err", err, "storageMsgList", storageMessageList)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
log.ZInfo(ctx, "BatchInsertChat2Cache end")
|
||||||
|
|
||||||
if isNewConversation {
|
if isNewConversation {
|
||||||
switch msg.SessionType {
|
switch msg.SessionType {
|
||||||
case constant.ReadGroupChatType:
|
case constant.ReadGroupChatType:
|
||||||
@ -263,6 +266,8 @@ func (och *OnlineHistoryRedisConsumerHandler) handleMsg(ctx context.Context, key
|
|||||||
log.ZWarn(ctx, "get group member ids error", err, "conversationID",
|
log.ZWarn(ctx, "get group member ids error", err, "conversationID",
|
||||||
conversationID)
|
conversationID)
|
||||||
} else {
|
} else {
|
||||||
|
log.ZInfo(ctx, "GetGroupMemberIDs end")
|
||||||
|
|
||||||
if err := och.conversationRpcClient.GroupChatFirstCreateConversation(ctx,
|
if err := och.conversationRpcClient.GroupChatFirstCreateConversation(ctx,
|
||||||
msg.GroupID, userIDs); err != nil {
|
msg.GroupID, userIDs); err != nil {
|
||||||
log.ZWarn(ctx, "single chat first create conversation error", err,
|
log.ZWarn(ctx, "single chat first create conversation error", err,
|
||||||
@ -281,13 +286,16 @@ func (och *OnlineHistoryRedisConsumerHandler) handleMsg(ctx context.Context, key
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZDebug(ctx, "success incr to next topic")
|
log.ZInfo(ctx, "success incr to next topic")
|
||||||
err = och.msgDatabase.MsgToMongoMQ(ctx, key, conversationID, storageMessageList, lastSeq)
|
err = och.msgDatabase.MsgToMongoMQ(ctx, key, conversationID, storageMessageList, lastSeq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(ctx, "Msg To MongoDB MQ error", err, "conversationID",
|
log.ZError(ctx, "Msg To MongoDB MQ error", err, "conversationID",
|
||||||
conversationID, "storageList", storageMessageList, "lastSeq", lastSeq)
|
conversationID, "storageList", storageMessageList, "lastSeq", lastSeq)
|
||||||
}
|
}
|
||||||
|
log.ZInfo(ctx, "MsgToMongoMQ end")
|
||||||
|
|
||||||
och.toPushTopic(ctx, key, conversationID, storageList)
|
och.toPushTopic(ctx, key, conversationID, storageList)
|
||||||
|
log.ZInfo(ctx, "toPushTopic end")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -135,20 +135,27 @@ func (c *ConsumerHandler) ConsumeClaim(sess sarama.ConsumerGroupSession, claim s
|
|||||||
|
|
||||||
// Push2User Suitable for two types of conversations, one is SingleChatType and the other is NotificationChatType.
|
// Push2User Suitable for two types of conversations, one is SingleChatType and the other is NotificationChatType.
|
||||||
func (c *ConsumerHandler) Push2User(ctx context.Context, userIDs []string, msg *sdkws.MsgData) (err error) {
|
func (c *ConsumerHandler) Push2User(ctx context.Context, userIDs []string, msg *sdkws.MsgData) (err error) {
|
||||||
log.ZDebug(ctx, "Get msg from msg_transfer And push msg", "userIDs", userIDs, "msg", msg.String())
|
log.ZInfo(ctx, "Get msg from msg_transfer And push msg", "userIDs", userIDs, "msg", msg.String())
|
||||||
|
defer func(duration time.Time) {
|
||||||
|
t := time.Since(duration)
|
||||||
|
log.ZInfo(ctx, "Get msg from msg_transfer And push msg", "msg", msg.String(), "time cost", t)
|
||||||
|
}(time.Now())
|
||||||
if err := c.webhookBeforeOnlinePush(ctx, &c.config.WebhooksConfig.BeforeOnlinePush, userIDs, msg); err != nil {
|
if err := c.webhookBeforeOnlinePush(ctx, &c.config.WebhooksConfig.BeforeOnlinePush, userIDs, msg); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.ZInfo(ctx, "webhookBeforeOnlinePush end")
|
||||||
|
|
||||||
wsResults, err := c.GetConnsAndOnlinePush(ctx, msg, userIDs)
|
wsResults, err := c.GetConnsAndOnlinePush(ctx, msg, userIDs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.ZDebug(ctx, "single and notification push result", "result", wsResults, "msg", msg, "push_to_userID", userIDs)
|
log.ZInfo(ctx, "single and notification push result", "result", wsResults, "msg", msg, "push_to_userID", userIDs)
|
||||||
|
|
||||||
if !c.shouldPushOffline(ctx, msg) {
|
if !c.shouldPushOffline(ctx, msg) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
log.ZInfo(ctx, "shouldPushOffline end")
|
||||||
|
|
||||||
for _, v := range wsResults {
|
for _, v := range wsResults {
|
||||||
//message sender do not need offline push
|
//message sender do not need offline push
|
||||||
@ -167,7 +174,7 @@ func (c *ConsumerHandler) Push2User(ctx context.Context, userIDs []string, msg *
|
|||||||
offlinePushUserID, msg, nil); err != nil {
|
offlinePushUserID, msg, nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.ZInfo(ctx, "webhookBeforeOfflinePush end")
|
||||||
err = c.offlinePushMsg(ctx, msg, offlinePushUserID)
|
err = c.offlinePushMsg(ctx, msg, offlinePushUserID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZWarn(ctx, "offlinePushMsg failed", err, "offlinePushUserID", offlinePushUserID, "msg", msg)
|
log.ZWarn(ctx, "offlinePushMsg failed", err, "offlinePushUserID", offlinePushUserID, "msg", msg)
|
||||||
@ -267,7 +274,6 @@ func (c *ConsumerHandler) Push2Group(ctx context.Context, groupID string, msg *s
|
|||||||
log.ZWarn(ctx, "offlinePushMsg failed", err, "groupID", groupID, "msg", msg)
|
log.ZWarn(ctx, "offlinePushMsg failed", err, "groupID", groupID, "msg", msg)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user