haozhifeng
2021-08-12 508a1fc8f2d5cde4116371d2adec012f57aef807
ruleserver 日志
1个文件已修改
1个文件已添加
34 ■■■■■ 已修改文件
logc.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruleServerLog.go 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
logc.go
@@ -108,6 +108,10 @@
    deliverLog(log, timeout)
}
func SaveRuleServerLog(ruleServerPushLog RuleServerPushLog, timeout time.Duration) {
    deliverLog(&ruleServerPushLog, timeout)
}
func deliverLog(l LogPrinter, timeout time.Duration) {
    select {
    case logCh <- l:
@@ -162,6 +166,7 @@
const (
    OperationLogTopic = "operationLogSaveTopic"
    ScheduleLogTopic = "scheduleLogSaveTopic"
    RuleServerLogTopic = "ruleServerLogSaveTopic"
)
func saveLoop(logCallback LogReportCallback, wg *sync.WaitGroup, done  chan struct{}) {
ruleServerLog.go
New file
@@ -0,0 +1,29 @@
package logc
import "encoding/json"
type RuleServerLog struct {
    ID           string `gorm:"column:id;primaryKey;unique;autoIncrement" json:"id"` // 主键id
    Name         string `gorm:"column:name" json:"name"`
    State        string `gorm:"column:state" json:"state"`
    TotalSuccess int    `gorm:"column:totalSuccess" json:"totalSuccess"`
    TotalFailure int    `gorm:"column:totalFailure" json:"totalFailure"`
    TotalCached  string `gorm:"column:totalCached" json:"totalCached"`
    LastSendDate string `gorm:"column:lastSendDate" json:"lastSendDate"`
    CreateDate   int64  `gorm:"column:createDate" json:"createDate"`
}
type RuleServerPushLog struct {
    ID       string // 主键id
    TaskName string // 任务名称
    Type     int    // 消息类型: 0 更新状态 1 成功+1 2 失败+1 3 缓存上报
    Info     string // 详情
}
func (l *RuleServerPushLog) Marshal() ([]byte, error) {
    return json.Marshal(l)
}
func (l *RuleServerPushLog) Topic() string {
    return RuleServerLogTopic
}