update log format --all replace

This commit is contained in:
engigu
2024-01-13 12:04:40 +08:00
parent c0241df60c
commit e76782451b
9 changed files with 41 additions and 37 deletions
+5 -5
View File
@@ -3,10 +3,10 @@ package cron_service
import (
"fmt"
"github.com/robfig/cron/v3"
"github.com/sirupsen/logrus"
"github.com/unknwon/com"
"message-nest/models"
"message-nest/pkg/constant"
"message-nest/pkg/logging"
"message-nest/service/send_message_service"
)
@@ -47,7 +47,7 @@ func (cs *CronService) InitLogsCronRun() {
// 注册任务
setting, err := models.GetSettingByKey(constant.LogsCleanSectionName, constant.LogsCleanCronKeyName)
if err != nil {
logging.Logger.Error(fmt.Sprintf("获取日志的cron失败,原因:%s", err))
logrus.Error(fmt.Sprintf("获取日志的cron失败,原因:%s", err))
}
ClearLogsTaskId = AddTask(ScheduledTask{
Schedule: setting.Value,
@@ -57,7 +57,7 @@ func (cs *CronService) InitLogsCronRun() {
// 添加任务
err = models.AddSendTaskWithID("日志定时清除", constant.CleanLogsTaskId, "admin")
if err != nil {
logging.Logger.Error(fmt.Sprintf("添加日志定时清除任务失败,原因:%s", err))
logrus.Error(fmt.Sprintf("添加日志定时清除任务失败,原因:%s", err))
}
}
@@ -68,8 +68,8 @@ func (cs *CronService) UpdateLogsCronRun(cron string) {
Schedule: cron,
Job: ClearLogs,
})
logging.Logger.Error(fmt.Sprintf("更新日志的cron成功,%s", cron))
logging.Logger.Error(fmt.Sprintf("所有的定时任务: %s", TaskList))
logrus.Error(fmt.Sprintf("更新日志的cron成功,%s", cron))
logrus.Error(fmt.Sprintf("所有的定时任务: %s", TaskList))
}
+4 -3
View File
@@ -3,7 +3,8 @@ package cron_service
import (
"fmt"
"github.com/robfig/cron/v3"
"message-nest/pkg/logging"
"github.com/sirupsen/logrus"
"sync"
)
@@ -33,10 +34,10 @@ func AddTask(task ScheduledTask) cron.EntryID {
taskId, err := CronInstance.AddFunc(task.Schedule, task.Job)
if err != nil {
// 处理错误
logging.Logger.Error(fmt.Sprintf("添加定时任务失败,原因:%s", err))
logrus.Error(fmt.Sprintf("添加定时任务失败,原因:%s", err))
} else {
TaskList[taskId] = &task
logging.Logger.Error(fmt.Sprintf("添加定时任务成功,entryID: %d, cron: %s", taskId, task.Schedule))
logrus.Error(fmt.Sprintf("添加定时任务成功,entryID: %d, cron: %s", taskId, task.Schedule))
}
return taskId
}
+3 -3
View File
@@ -1,9 +1,9 @@
package env_service
import (
"github.com/sirupsen/logrus"
"message-nest/models"
"message-nest/pkg/constant"
"message-nest/pkg/logging"
)
type EnvService struct {
@@ -18,9 +18,9 @@ func (es *EnvService) CommonAdd(section string, key string, value string) {
Value: value,
})
if err != nil {
logging.Logger.Error("初始化%s:%s失败", section, key)
logrus.Error("初始化%s:%s失败", section, key)
} else {
logging.Logger.Infof("初始化%s:%s成功", section, key)
logrus.Infof("初始化%s:%s成功", section, key)
}
}
}
+4 -3
View File
@@ -1,8 +1,9 @@
package send_message_service
import (
"github.com/sirupsen/logrus"
"message-nest/pkg/constant"
"message-nest/pkg/logging"
"sync"
)
@@ -13,7 +14,7 @@ func DoSendTask(task SendMessageService, wg *sync.WaitGroup) {
defer wg.Done()
defer func() {
if r := recover(); r != nil {
logging.Logger.Error("DoSendTask: Recovered from panic:", r)
logrus.Error("DoSendTask: Recovered from panic:", r)
}
}()
@@ -31,7 +32,7 @@ func MessageConsumer(wg *sync.WaitGroup) {
for {
task, ok := <-Buffer
if !ok {
logging.Logger.Error("MessageConsumer: Channel closed. Exiting.")
logrus.Error("MessageConsumer: Channel closed. Exiting.")
return
}
+5 -5
View File
@@ -2,8 +2,8 @@ package send_message_service
import (
"fmt"
"github.com/sirupsen/logrus"
"message-nest/models"
"message-nest/pkg/logging"
"message-nest/service/send_task_service"
"message-nest/service/send_way_service"
"strings"
@@ -38,7 +38,7 @@ func (sm *SendMessageService) LogsAndStatusMark(errStr string, status int) {
if status == SendFail {
sm.Status = SendFail
}
logging.Logger.Error(fmt.Sprintf("%s, 状态:%d", errStr, status))
logrus.Error(fmt.Sprintf("%s, 状态:%d", errStr, status))
}
// Send 发送一个消息任务的所有实例
@@ -158,7 +158,7 @@ func (sm *SendMessageService) RecordSendLog() {
}
err := log.Add()
if err != nil {
logging.Logger.Error(fmt.Sprintf("添加日志失败!原因是:%s", err))
logrus.Error(fmt.Sprintf("添加日志失败!原因是:%s", err))
}
}
@@ -182,10 +182,10 @@ func (sm *SendMessageService) GetSendMsg(ins models.SendTasksIns) (string, strin
if !ok || len(content) == 0 {
content, ok := data["text"]
if !ok {
logging.Logger.Error("text节点数据为空!")
logrus.Error("text节点数据为空!")
return "text", ""
} else {
logging.Logger.Error(fmt.Sprintf("没有找到%s对应的消息,使用text消息替代!", ins.ContentType))
logrus.Error(fmt.Sprintf("没有找到%s对应的消息,使用text消息替代!", ins.ContentType))
return "text", content
}
} else {