From 2730bb97ca3bb62ee3dcd6330012da24ce31ff05 Mon Sep 17 00:00:00 2001 From: engigu Date: Wed, 3 Jan 2024 22:08:45 +0800 Subject: [PATCH] logs fix --- go.mod | 1 + go.sum | 2 ++ service/cron_service/cron_service.go | 4 ---- service/send_message_service/send_message.go | 4 ++-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index b5391d8..11e9aba 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( ) require ( + github.com/blinkbean/dingtalk v0.0.0-20230927120905-796332ac4ba1 // indirect github.com/bytedance/sonic v1.10.2 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect github.com/chenzhuoyu/iasm v0.9.1 // indirect diff --git a/go.sum b/go.sum index 79da2db..e792ff9 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/blinkbean/dingtalk v0.0.0-20230927120905-796332ac4ba1 h1:G14RkaB3RRW099aQbfyHm4RFgNxGUOTeHSoN+CZy2YI= +github.com/blinkbean/dingtalk v0.0.0-20230927120905-796332ac4ba1/go.mod h1:9BaLuGSBqY3vT5hstValh48DbsKO7vaHaJnG9pXwbto= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= github.com/bytedance/sonic v1.10.2 h1:GQebETVBxYB7JGWJtLBi07OVzWwt+8dWA00gEVW2ZFE= diff --git a/service/cron_service/cron_service.go b/service/cron_service/cron_service.go index 675d2fb..10e65c4 100644 --- a/service/cron_service/cron_service.go +++ b/service/cron_service/cron_service.go @@ -21,13 +21,11 @@ func ClearLogs() { sm := send_message_service.SendMessageService{TaskID: constant.CleanLogsTaskId} sm.Status = send_message_service.SendSuccess - logging.Logger.Error("开始清除日志") sm.LogsAndStatusMark("开始清除日志", sm.Status) setting, err := models.GetSettingByKey(constant.LogsCleanSectionName, constant.LogsCleanKeepKeyName) if err != nil { errStr = fmt.Sprintf("获取日志的保留数失败,原因:%s", err) - logging.Logger.Error(errStr) sm.LogsAndStatusMark(errStr, send_message_service.SendFail) } @@ -35,11 +33,9 @@ func ClearLogs() { affectedRows, err := models.DeleteOutDateLogs(keepNum) if err != nil { errStr = fmt.Sprintf("删除日志失败,原因:%s", err) - logging.Logger.Error(errStr) sm.LogsAndStatusMark(errStr, send_message_service.SendFail) } else { errStr = fmt.Sprintf("删除日志成功,删除条数:%d,保留数目:%d", affectedRows, keepNum) - logging.Logger.Error(errStr) sm.LogsAndStatusMark(errStr, sm.Status) } diff --git a/service/send_message_service/send_message.go b/service/send_message_service/send_message.go index 527b81a..b0589a4 100644 --- a/service/send_message_service/send_message.go +++ b/service/send_message_service/send_message.go @@ -37,7 +37,7 @@ func (sm *SendMessageService) LogsAndStatusMark(errStr string, status int) { if status == SendFail { sm.Status = SendFail } - logging.Logger.Info(fmt.Sprintf("%s, 状态:%d", errStr, status)) + logging.Logger.Error(fmt.Sprintf("%s, 状态:%d", errStr, status)) } // Send 发送一个消息任务的所有实例 @@ -112,7 +112,7 @@ func (sm *SendMessageService) Send() string { return strings.Join(sm.LogOutput, "\n") } -// FormatSendContent 格式化输出的发送内容 +// AppendSendContent 添加发送内容 func (sm *SendMessageService) AppendSendContent() { sm.LogOutput = append(sm.LogOutput, fmt.Sprintf(">> 发送的内容:")) if sm.Text != "" {