etcdserver,embed: discard gRPC info logs when debug is off

Signed-off-by: Gyuho Lee <gyuhox@gmail.com>

Conflicts:
	embed/etcd.go
	etcdserver/api/v3rpc/grpc.go
	etcdserver/config.go
This commit is contained in:
Gyuho Lee 2018-01-02 07:40:50 -08:00
parent 4ab213a4ec
commit 7025d7c665
3 changed files with 13 additions and 4 deletions

View File

@ -146,6 +146,7 @@ func StartEtcd(inCfg *Config) (e *Etcd, err error) {
StrictReconfigCheck: cfg.StrictReconfigCheck,
ClientCertAuthEnabled: cfg.ClientTLSInfo.ClientCertAuth,
AuthToken: cfg.AuthToken,
Debug: cfg.Debug,
}
if e.Server, err = etcdserver.NewServer(srvcfg); err != nil {

View File

@ -16,7 +16,9 @@ package v3rpc
import (
"crypto/tls"
"io/ioutil"
"math"
"os"
"github.com/coreos/etcd/etcdserver"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
@ -31,10 +33,6 @@ const (
maxSendBytes = math.MaxInt32
)
func init() {
grpclog.SetLogger(plog)
}
func Server(s *etcdserver.EtcdServer, tls *tls.Config, gopts ...grpc.ServerOption) *grpc.Server {
var opts []grpc.ServerOption
opts = append(opts, grpc.CustomCodec(&codec{}))
@ -55,5 +53,13 @@ func Server(s *etcdserver.EtcdServer, tls *tls.Config, gopts ...grpc.ServerOptio
pb.RegisterAuthServer(grpcServer, NewAuthServer(s))
pb.RegisterMaintenanceServer(grpcServer, NewMaintenanceServer(s))
if s.Cfg.Debug {
grpc.EnableTracing = true
// enable info, warning, error
grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr))
} else {
// only discard info
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, os.Stderr, os.Stderr))
}
return grpcServer
}

View File

@ -64,6 +64,8 @@ type ServerConfig struct {
ClientCertAuthEnabled bool
AuthToken string
Debug bool
}
// VerifyBootstrap sanity-checks the initial config for bootstrap case