github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/cmd/consensus/notifier.go (about) 1 package main 2 3 import ( 4 "github.com/rs/zerolog" 5 6 "github.com/onflow/flow-go/consensus/hotstuff/notifications" 7 "github.com/onflow/flow-go/consensus/hotstuff/notifications/pubsub" 8 "github.com/onflow/flow-go/model/flow" 9 "github.com/onflow/flow-go/module" 10 metricsconsumer "github.com/onflow/flow-go/module/metrics/hotstuff" 11 ) 12 13 // createLogger creates logger which reports chain ID on every log message. 14 func createLogger(log zerolog.Logger, chainID flow.ChainID) zerolog.Logger { 15 return log.With().Str("chain", chainID.String()).Logger() 16 } 17 18 // createNotifier creates a pubsub distributor and connects it to consensus consumers. 19 func createNotifier(log zerolog.Logger, metrics module.HotstuffMetrics) *pubsub.Distributor { 20 metricsConsumer := metricsconsumer.NewMetricsConsumer(metrics) 21 logsConsumer := notifications.NewLogConsumer(log) 22 dis := pubsub.NewDistributor() 23 dis.AddConsumer(metricsConsumer) 24 dis.AddConsumer(logsConsumer) 25 return dis 26 }