From c0c08fe373344542aaf6f95e28b58cc6b7f713e2 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 2 Mar 2022 20:59:54 +0800 Subject: [PATCH 1/5] adjust log --- internal/msg_gateway/gate/ws_server.go | 2 +- internal/push/logic/push_to_client.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index 0f751b58d..ff7e739c8 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -182,7 +182,7 @@ func (ws *WServer) addUserConn(uid string, platformID int32, conn *UserConn, tok for _, v := range ws.wsUserToConn { count = count + len(v) } - log.WarnByKv("WS Add operation", "", "wsUser added", ws.wsUserToConn, "connection_uid", uid, "connection_platform", constant.PlatformIDToName(platformID), "online_user_num", len(ws.wsUserToConn), "online_conn_num", count) + log.Debug("WS Add operation", "", "wsUser added", ws.wsUserToConn, "connection_uid", uid, "connection_platform", constant.PlatformIDToName(platformID), "online_user_num", len(ws.wsUserToConn), "online_conn_num", count) userCount = uint64(len(ws.wsUserToConn)) } diff --git a/internal/push/logic/push_to_client.go b/internal/push/logic/push_to_client.go index b6a624f91..11d090ac5 100644 --- a/internal/push/logic/push_to_client.go +++ b/internal/push/logic/push_to_client.go @@ -31,10 +31,10 @@ type AtContent struct { func MsgToUser(pushMsg *pbPush.PushMsgReq) { var wsResult []*pbRelay.SingleMsgToUser //isOfflinePush := utils.GetSwitchFromOptions(pushMsg.MsgData.Options, constant.IsOfflinePush) - log.InfoByKv("Get msg from msg_transfer And push msg", pushMsg.OperationID, "PushData", pushMsg.String()) + log.Debug("Get msg from msg_transfer And push msg", pushMsg.OperationID, "PushData", pushMsg.String()) grpcCons := getcdv3.GetConn4Unique(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImOnlineMessageRelayName) //Online push message - log.InfoByKv("test", pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String()) + log.Debug("test", pushMsg.OperationID, "len grpc", len(grpcCons), "data", pushMsg.String()) for _, v := range grpcCons { msgClient := pbRelay.NewOnlineMessageRelayServiceClient(v) reply, err := msgClient.OnlinePushMsg(context.Background(), &pbRelay.OnlinePushMsgReq{OperationID: pushMsg.OperationID, MsgData: pushMsg.MsgData, PushToUserID: pushMsg.PushToUserID}) From e6b302abf9c51bccd121b563f09339a1a7f6f4f9 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Wed, 2 Mar 2022 21:02:21 +0800 Subject: [PATCH 2/5] log --- pkg/common/http/http_client.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/common/http/http_client.go b/pkg/common/http/http_client.go index 38d18c119..e227da91e 100644 --- a/pkg/common/http/http_client.go +++ b/pkg/common/http/http_client.go @@ -62,4 +62,5 @@ func PostReturn(url string, input, output interface{}, timeOut int) error { if err = json.Unmarshal(b, output); err != nil { return err } + return nil } From 25f24801d6acb46c81364dd2c0a342af7f01dc92 Mon Sep 17 00:00:00 2001 From: FG <1432970085@qq.com> Date: Wed, 2 Mar 2022 22:52:39 +0800 Subject: [PATCH 3/5] log --- pkg/common/log/logrus.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pkg/common/log/logrus.go b/pkg/common/log/logrus.go index 63485e8d9..a5e0ae7dd 100644 --- a/pkg/common/log/logrus.go +++ b/pkg/common/log/logrus.go @@ -2,6 +2,7 @@ package log import ( "Open_IM/pkg/common/config" + "bufio" "fmt" "os" "time" @@ -32,13 +33,13 @@ func loggerInit(moduleName string) *Logger { //All logs will be printed logger.SetLevel(logrus.Level(config.Config.Log.RemainLogLevel)) //Close std console output - //src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend) - //if err != nil { - // panic(err.Error()) - //} - //writer := bufio.NewWriter(src) - //logger.SetOutput(writer) - logger.SetOutput(os.Stdout) + src, err := os.OpenFile(os.DevNull, os.O_APPEND|os.O_WRONLY, os.ModeAppend) + if err != nil { + panic(err.Error()) + } + writer := bufio.NewWriter(src) + logger.SetOutput(writer) + //logger.SetOutput(os.Stdout) //Log Console Print Style Setting logger.SetFormatter(&nested.Formatter{ TimestampFormat: "2006-01-02 15:04:05.000", From d8a729c961f55a552d81c71de6d6bafb5c862810 Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 3 Mar 2022 10:53:44 +0800 Subject: [PATCH 4/5] config update --- config/config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.yaml b/config/config.yaml index 7d025c863..9d1f7f71b 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -180,7 +180,7 @@ tokenpolicy: messagecallback: callbackSwitch: false - callbackUrl: "http://www.xxx.com/msg/judge" + callbackUrl: "http://www.uuu.com/msg/judge" #TimeOut use second as unit callbackTimeOut: 10 messagejudge: From 97ec9602f7e83b012e3026e8bcc9a65904fd1c3f Mon Sep 17 00:00:00 2001 From: Gordon <1432970085@qq.com> Date: Thu, 3 Mar 2022 12:11:38 +0800 Subject: [PATCH 5/5] callback note --- internal/rpc/msg/send_msg.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/rpc/msg/send_msg.go b/internal/rpc/msg/send_msg.go index 86a28d480..b4581456a 100644 --- a/internal/rpc/msg/send_msg.go +++ b/internal/rpc/msg/send_msg.go @@ -126,14 +126,14 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S } // callback - canSend, err := callBackWordFilter(pb) - if err != nil { - log.NewError(pb.OperationID, utils.GetSelfFuncName(), "CallbackBeforeSendMsg failed", err.Error(), pb.MsgData) - } - if !canSend { - log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callback result", canSend, "end rpc and return", pb.MsgData) - return returnMsg(&replay, pb, 201, "callback result stop rpc and return", "", 0) - } + //canSend, err := callBackWordFilter(pb) + //if err != nil { + // log.NewError(pb.OperationID, utils.GetSelfFuncName(), "CallbackBeforeSendMsg failed", err.Error(), pb.MsgData) + //} + //if !canSend { + // log.NewDebug(pb.OperationID, utils.GetSelfFuncName(), "callback result", canSend, "end rpc and return", pb.MsgData) + // return returnMsg(&replay, pb, 201, "callback result stop rpc and return", "", 0) + //} switch pb.MsgData.SessionType { case constant.SingleChatType: canSend, err := callbackBeforeSendSingleMsg(pb)