fix for issue 2976 (#3313)

fix for null pointer exception in ZookeeperLogger
This commit is contained in:
Alexander Kazarin 2017-10-18 19:02:20 +03:00 committed by Brian Brazil
parent bf4a279a91
commit 2c163f32a5
2 changed files with 6 additions and 1 deletions

View file

@ -68,7 +68,7 @@ func NewDiscovery(
}
conn, _, err := zk.Connect(srvs, timeout)
conn.SetLogger(treecache.ZookeeperLogger{})
conn.SetLogger(treecache.NewZookeeperLogger(logger))
if err != nil {
return nil
}

View file

@ -49,6 +49,11 @@ type ZookeeperLogger struct {
logger log.Logger
}
// NewZookeeperLogger is a constructor for ZookeeperLogger
func NewZookeeperLogger(logger log.Logger) ZookeeperLogger {
return ZookeeperLogger{logger: logger}
}
// Implements zk.Logger
func (zl ZookeeperLogger) Printf(s string, i ...interface{}) {
level.Info(zl.logger).Log("msg", fmt.Sprintf(s, i...))