diff --git a/cmd/new_event.go b/cmd/new_event.go index 3567481..d72702e 100644 --- a/cmd/new_event.go +++ b/cmd/new_event.go @@ -127,7 +127,7 @@ func commandNewEventE(cmd *cobra.Command, args []string) error { // 写入或追加 topic 常量,避免重复。 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 { fmt.Printf("[dry-run] ensure topics file and add constant > %s\n", topicsPath) diff --git a/templates/events/subscriber.go.tpl b/templates/events/subscriber.go.tpl index 7ce14c1..5ff8b0c 100644 --- a/templates/events/subscriber.go.tpl +++ b/templates/events/subscriber.go.tpl @@ -23,7 +23,7 @@ type {{.Name}}Subscriber struct { } 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 }