From a41f834192fad86fc684b519cd98afe59e5832b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 3 Jan 2022 15:53:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=89=93=E5=8D=B0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=9B=B8=E5=85=B3=E6=97=A5=E5=BF=97=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/remotelogs/utils.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/internal/remotelogs/utils.go b/internal/remotelogs/utils.go index 1d7c61e..7a16214 100644 --- a/internal/remotelogs/utils.go +++ b/internal/remotelogs/utils.go @@ -173,6 +173,39 @@ func ServerSuccess(serverId int64, tag string, description string, logType nodec } } + +// ServerLog 打印服务相关日志信息 +func ServerLog(serverId int64, tag string, description string, logType nodeconfigs.NodeLogType, params maps.Map) { + logs.Println("[" + tag + "]" + description) + + // 参数 + var paramsJSON []byte + if len(params) > 0 { + p, err := json.Marshal(params) + if err != nil { + logs.Println("[LOG]" + err.Error()) + } else { + paramsJSON = p + } + } + + select { + case logChan <- &pb.NodeLog{ + Role: teaconst.Role, + Tag: tag, + Description: description, + Level: "info", + NodeId: teaconst.NodeId, + ServerId: serverId, + CreatedAt: time.Now().Unix(), + Type: logType, + ParamsJSON: paramsJSON, + }: + default: + + } +} + // 上传日志 func uploadLogs() error { logList := []*pb.NodeLog{}