diff --git a/clientv3/client.go b/clientv3/client.go index 4d1270e8aef..eae8491e4ea 100644 --- a/clientv3/client.go +++ b/clientv3/client.go @@ -21,6 +21,7 @@ import ( "fmt" "net" "net/url" + "os" "strconv" "strings" "sync" @@ -49,13 +50,18 @@ var ( ) func init() { + lg := zap.NewNop() + if os.Getenv("ETCD_CLIENT_DEBUG") != "" { + var err error + lg, err = zap.NewProductionConfig().Build() // info level logging + if err != nil { + panic(err) + } + } balancer.RegisterBuilder(balancer.Config{ Policy: picker.RoundrobinBalanced, Name: roundRobinBalancerName, - - // TODO: configure from clientv3.Config - Logger: zap.NewNop(), - // Logger: zap.NewExample(), + Logger: lg, }) } diff --git a/clientv3/config.go b/clientv3/config.go index c81d56466fc..4cea369076e 100644 --- a/clientv3/config.go +++ b/clientv3/config.go @@ -76,7 +76,7 @@ type Config struct { // LogConfig configures client-side logger. // If nil, use the default logger. - // TODO: configure balancer and gRPC logger + // TODO: configure gRPC logger LogConfig *zap.Config } diff --git a/clientv3/doc.go b/clientv3/doc.go index 0bb68618965..cd6ef01d213 100644 --- a/clientv3/doc.go +++ b/clientv3/doc.go @@ -99,4 +99,8 @@ // } // } // +// The grpc load balancer is registered statically and is shared across etcd clients. +// To enable detailed load balancer logging, set the ETCD_CLIENT_DEBUG environment +// variable. E.g. "ETCD_CLIENT_DEBUG=1". +// package clientv3