Skip to content

Commit

Permalink
Merge pull request #11 from mailgun/maxim/develop
Browse files Browse the repository at this point in the history
Allow using any logger
  • Loading branch information
smira authored Sep 12, 2018
2 parents 5f0eec3 + 3d01e6a commit cc7284a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ SOFTWARE.
*/

import (
"log"
"time"
)

Expand All @@ -43,6 +42,12 @@ const (
DefaultSendLoopCount = 1
)

// SomeLogger defines logging interface that allows using 3rd party loggers
// (e.g. github.com/sirupsen/logrus) with this Statsd client.
type SomeLogger interface {
Printf(fmt string, args ...interface{})
}

// ClientOptions are statsd client settings
type ClientOptions struct {
// Addr is statsd server address in "host:port" format
Expand Down Expand Up @@ -90,7 +95,7 @@ type ClientOptions struct {
// Logger is used by statsd client to report errors and lost packets
//
// If not set, default logger to stderr with prefix `[STATSD] ` is being used
Logger *log.Logger
Logger SomeLogger

// BufPoolCapacity controls size of pre-allocated buffer cache
//
Expand Down Expand Up @@ -200,7 +205,7 @@ func ReportInterval(interval time.Duration) Option {
// Logger is used by statsd client to report errors and lost packets
//
// If not set, default logger to stderr with prefix `[STATSD] ` is being used
func Logger(logger *log.Logger) Option {
func Logger(logger SomeLogger) Option {
return func(c *ClientOptions) {
c.Logger = logger
}
Expand Down

0 comments on commit cc7284a

Please sign in to comment.