1
0
mirror of https://github.com/go-kit/kit.git synced 2025-07-15 01:04:44 +02:00
Files
go-kit/sd/zk/logwrapper.go

28 lines
625 B
Go
Raw Permalink Normal View History

2016-05-25 15:39:18 -06:00
package zk
import (
"fmt"
"github.com/go-zookeeper/zk"
2016-05-25 15:39:18 -06:00
"github.com/go-kit/log"
2016-05-25 15:39:18 -06:00
)
// wrapLogger wraps a Go kit logger so we can use it as the logging service for
// the ZooKeeper library, which expects a Printf method to be available.
type wrapLogger struct {
log.Logger
}
func (logger wrapLogger) Printf(format string, args ...interface{}) {
logger.Log("msg", fmt.Sprintf(format, args...))
}
// withLogger replaces the ZooKeeper library's default logging service with our
// own Go kit logger.
func withLogger(logger log.Logger) func(c *zk.Conn) {
return func(c *zk.Conn) {
c.SetLogger(wrapLogger{logger})
}
}