...

Source file src/github.com/go-kit/kit/sd/zk/logwrapper.go

Documentation: github.com/go-kit/kit/sd/zk

     1  package zk
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/go-zookeeper/zk"
     7  
     8  	"github.com/go-kit/log"
     9  )
    10  
    11  // wrapLogger wraps a Go kit logger so we can use it as the logging service for
    12  // the ZooKeeper library, which expects a Printf method to be available.
    13  type wrapLogger struct {
    14  	log.Logger
    15  }
    16  
    17  func (logger wrapLogger) Printf(format string, args ...interface{}) {
    18  	logger.Log("msg", fmt.Sprintf(format, args...))
    19  }
    20  
    21  // withLogger replaces the ZooKeeper library's default logging service with our
    22  // own Go kit logger.
    23  func withLogger(logger log.Logger) func(c *zk.Conn) {
    24  	return func(c *zk.Conn) {
    25  		c.SetLogger(wrapLogger{logger})
    26  	}
    27  }
    28  

View as plain text