Skip to content

Commit

Permalink
Merge pull request #1739 from ripienaar/adapter_info_spam.2
Browse files Browse the repository at this point in the history
(misc) Avoid using global logrus
  • Loading branch information
ripienaar authored Jun 21, 2022
2 parents e458c3c + 76080ad commit 5019362
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
9 changes: 4 additions & 5 deletions broker/adapter/ingest/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import (
"github.com/choria-io/go-choria/config"
"github.com/choria-io/go-choria/inter"
"github.com/prometheus/client_golang/prometheus"

log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)

// Adaptable matches both protocol.Request and protocol.Reply
Expand All @@ -39,11 +38,11 @@ type NatsIngest struct {

fw inter.Framework
cfg *config.Config
log *log.Entry
log *logrus.Entry
conn inter.Connector
}

func New(name string, work chan Adaptable, fw inter.Framework, logger *log.Entry) ([]*NatsIngest, error) {
func New(name string, work chan Adaptable, fw inter.Framework, logger *logrus.Entry) ([]*NatsIngest, error) {
prefix := fmt.Sprintf("plugin.choria.adapter.%s.ingest.", name)
cfg := fw.Configuration()

Expand Down Expand Up @@ -81,7 +80,7 @@ func New(name string, work chan Adaptable, fw inter.Framework, logger *log.Entry
proto: proto,
fw: fw,
cfg: fw.Configuration(),
log: logger.WithFields(log.Fields{"side": "ingest", "instance": i}),
log: logger.WithFields(logrus.Fields{"side": "ingest", "instance": i}),
}

workers = append(workers, n)
Expand Down
6 changes: 3 additions & 3 deletions broker/adapter/streams/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/choria-io/go-choria/broker/adapter/stats"
"github.com/choria-io/go-choria/config"
"github.com/choria-io/go-choria/inter"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)

// Streams is an adapter that connects a NATS topic with messages sent from Choria
Expand Down Expand Up @@ -44,7 +44,7 @@ type Streams struct {
streams []*stream
ingests []*ingest.NatsIngest
work chan ingest.Adaptable
log *log.Entry
log *logrus.Entry
}

var fw inter.Framework
Expand All @@ -63,7 +63,7 @@ func Create(name string, choria inter.Framework) (adapter *Streams, err error) {
stats.WorkQueueCapacityGauge.WithLabelValues(name, cfg.Identity).Set(float64(worklen))

adapter = &Streams{
log: log.WithFields(log.Fields{"component": "streams_adapter", "name": name}),
log: fw.Logger("streams_adapter").WithFields(logrus.Fields{"name": name}),
work: make(chan ingest.Adaptable, worklen),
}

Expand Down
8 changes: 4 additions & 4 deletions broker/adapter/streams/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ import (
"github.com/choria-io/go-choria/internal/util"
"github.com/choria-io/go-choria/srvcache"
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
)

type stream struct {
servers func() (srvcache.Servers, error)
clientID string
topic string
conn inter.Connector
log *log.Entry
log *logrus.Entry
name string
adapterName string

work chan ingest.Adaptable
}

func newStream(name string, work chan ingest.Adaptable, logger *log.Entry) ([]*stream, error) {
func newStream(name string, work chan ingest.Adaptable, logger *logrus.Entry) ([]*stream, error) {
prefix := fmt.Sprintf("plugin.choria.adapter.%s.stream.", name)

instances, err := strconv.Atoi(cfg.Option(prefix+"workers", "10"))
Expand Down Expand Up @@ -63,7 +63,7 @@ func newStream(name string, work chan ingest.Adaptable, logger *log.Entry) ([]*s
name: fmt.Sprintf("%s.%d", name, i),
adapterName: name,
work: work,
log: logger.WithFields(log.Fields{"side": "stream", "instance": i}),
log: logger.WithFields(logrus.Fields{"side": "stream", "instance": i}),
}

if servers != "" {
Expand Down

0 comments on commit 5019362

Please sign in to comment.