Skip to content

Commit 07095ca

Browse files
authored
Fix custom logger assignment (#9)
* In `consumer.go` the `NewConsumer` function was testing if the `Logger` attribute on the Config struct is `nil` and if it was it assigned the consumer logger to `&defaultLogger{}` but if the Config.Logger is not nil its value was never getting set on the consumer leaving consumer.logger == nil * In the `Logger` method on 109 there is a check for whether `consumer.logger == nil` and if it is we return `&defaultLogger{}` * Combined these to pieces of logic result in always ignoring a custom Logger attribute when it is set on Config. * This switches the logic in `NewConsumer` to match the pattern for other optional attributes by checking if the `Logger` attribute on the provided config is `!= nil` and setting consumer's logger to the provided logger * If there is no logger assigned on Config `consumer.logger` will remain `nil` and the `Logger` function will dutifly return a `&defaultLogger{}`
1 parent 91824b3 commit 07095ca

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

consumer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ func NewConsumer(c Config, queueName string) (Consumer, error) {
7575
extensionLimit: 2,
7676
}
7777

78-
if c.Logger == nil {
79-
cons.logger = &defaultLogger{}
78+
if c.Logger != nil {
79+
cons.logger = c.Logger
8080
}
8181

8282
if c.VisibilityTimeout != 0 {

0 commit comments

Comments
 (0)