feat: 更新事件主题常量格式,添加前缀以区分事件类型;增强订阅者日志记录,包含主题信息

This commit is contained in:
Rogee
2025-09-12 11:05:12 +08:00
parent c0a437a793
commit bddd8b1ba9
2 changed files with 2 additions and 2 deletions

View File

@@ -127,7 +127,7 @@ func commandNewEventE(cmd *cobra.Command, args []string) error {
// 写入或追加 topic 常量,避免重复。 // 写入或追加 topic 常量,避免重复。
topicsPath := filepath.Join(baseDir, "app/events/topics.go") topicsPath := filepath.Join(baseDir, "app/events/topics.go")
topicLine := fmt.Sprintf("const Topic%s = %q\n", camelName, snakeName) topicLine := fmt.Sprintf("const Topic%s = %q\n", camelName, "event:"+snakeName)
if dryRun { if dryRun {
fmt.Printf("[dry-run] ensure topics file and add constant > %s\n", topicsPath) fmt.Printf("[dry-run] ensure topics file and add constant > %s\n", topicsPath)

View File

@@ -23,7 +23,7 @@ type {{.Name}}Subscriber struct {
} }
func (e *{{.Name}}Subscriber) Prepare() error { func (e *{{.Name}}Subscriber) Prepare() error {
e.log = logrus.WithField("module", "events.subscribers.{{.Name}}Subscriber") e.log = logrus.WithField("module", "events.subscribers.{{.Name}}Subscriber").WithField("topic", e.Topic())
return nil return nil
} }