重构部分枚举, 让models包不依赖其他项目中的包
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/logs"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
||||
)
|
||||
|
||||
// logNotifier 实现了 Notifier 接口,用于将告警信息记录到日志中。
|
||||
@@ -24,10 +25,10 @@ func NewLogNotifier(ctx context.Context) Notifier {
|
||||
func (l *logNotifier) Send(ctx context.Context, content AlarmContent, toAddr string) error {
|
||||
logger := logs.TraceLogger(ctx, l.ctx, "Send")
|
||||
logger.Infow("告警已记录到日志",
|
||||
"notifierType", NotifierTypeLog,
|
||||
"notifierType", models.NotifierTypeLog,
|
||||
"title", content.Title,
|
||||
"message", content.Message,
|
||||
"level", content.Level.String(),
|
||||
"level", content.Level,
|
||||
"timestamp", content.Timestamp.Format(DefaultTimeFormat),
|
||||
"toAddr", toAddr,
|
||||
)
|
||||
@@ -35,6 +36,6 @@ func (l *logNotifier) Send(ctx context.Context, content AlarmContent, toAddr str
|
||||
}
|
||||
|
||||
// Type 返回通知器的类型。
|
||||
func (l *logNotifier) Type() NotifierType {
|
||||
return NotifierTypeLog
|
||||
func (l *logNotifier) Type() models.NotifierType {
|
||||
return models.NotifierTypeLog
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user