Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Commit

Permalink
Don't guard call to Logger, it should be set.
Browse files Browse the repository at this point in the history
  • Loading branch information
tealeg committed Nov 6, 2018
1 parent 0e3a9ed commit 6eabeb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
13 changes: 6 additions & 7 deletions consumer/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ type clusterConsumer interface {

// Consumer is a Kafka consumer.
type Consumer struct {
RetryInterval time.Duration
Metrics MetricsReporter
// If you wish to provide a different value for the Logger, you must do this prior to calling Serve.
Logger *log.Logger
newConsumer func(addrs []string, groupID string, topics []string, config *cluster.Config) (clusterConsumer, error)
consumer clusterConsumer
config *cluster.Config
handlers *handler.Collection
wg sync.WaitGroup
quit chan struct{}
RetryInterval time.Duration
Metrics MetricsReporter
newConsumer func(addrs []string, groupID string, topics []string, config *cluster.Config) (clusterConsumer, error)
Logger *log.Logger
}

// Handle registers the handler for the given topic.
Expand Down Expand Up @@ -139,9 +140,7 @@ func (c *Consumer) handlePartitions(ch <-chan cluster.PartitionConsumer) error {
c.handleMessages(pc.Messages(), c.consumer, pc, pc.Topic(), pc.Partition())
}(part)
case <-c.quit:
if c.Logger != nil {
c.Logger.Println("partition handler terminating")
}
c.Logger.Println("partition handler terminating")
return nil

}
Expand Down
5 changes: 2 additions & 3 deletions consumer/consumer_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,17 @@ const (
// TestLogger grabs logs in a buffer so we can later make assertions
// about them.
type TestLogger struct {
buf *bytes.Buffer
buf bytes.Buffer
Logger *log.Logger
t *testing.T
}

// NewTestLogger constructs a test logger we can make assertions against
func NewTestLogger(t *testing.T) *TestLogger {
tl := &TestLogger{
buf: bytes.NewBuffer([]byte{}),
t: t,
}
tl.Logger = log.New(tl.buf, "[Felice] ", log.LstdFlags)
tl.Logger = log.New(&tl.buf, "[Felice] ", log.LstdFlags)
return tl
}

Expand Down

0 comments on commit 6eabeb2

Please sign in to comment.