logging options added
This commit is contained in:
parent
4810a8666e
commit
e58b052251
1 changed files with 20 additions and 1 deletions
21
options.go
21
options.go
|
|
@ -1,6 +1,11 @@
|
||||||
package rabbit
|
package rabbit
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type Option func(*options)
|
type Option func(*options)
|
||||||
|
|
||||||
|
|
@ -39,3 +44,17 @@ func WithConsumerBurstSize(t int) Option {
|
||||||
op.consumerBurstSize = t
|
op.consumerBurstSize = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func WithLogger(l *log.Logger) Option {
|
||||||
|
return func(op *options) { op.logger = l }
|
||||||
|
}
|
||||||
|
|
||||||
|
func WithLogging(enabled bool) Option {
|
||||||
|
return func(op *options) {
|
||||||
|
if enabled {
|
||||||
|
op.logger = log.New(os.Stdout, "", log.LstdFlags)
|
||||||
|
} else {
|
||||||
|
op.logger = log.New(io.Discard, "", 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue