Skip to content

Commit

Permalink
Merge pull request #8861 from gyuho/coverage
Browse files Browse the repository at this point in the history
*: grpclog.SetLoggerV2 on clientv3.SetLogger, disable gRPC client logs
  • Loading branch information
gyuho authored Nov 12, 2017
2 parents a8fde60 + 5a154e8 commit 02ae7a3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion clientv3/integration/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ package integration
import (
"io/ioutil"

"github.com/coreos/etcd/clientv3"

"github.com/coreos/pkg/capnslog"
"google.golang.org/grpc/grpclog"
)

func init() {
capnslog.SetGlobalLogLevel(capnslog.CRITICAL)
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
clientv3.SetLogger(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
}
1 change: 1 addition & 0 deletions clientv3/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func GetLogger() Logger {
func (s *settableLogger) set(l Logger) {
s.mu.Lock()
logger.l = l
grpclog.SetLoggerV2(&logger)
s.mu.Unlock()
}

Expand Down
4 changes: 3 additions & 1 deletion clientv3/ordering/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ package ordering
import (
"io/ioutil"

"github.com/coreos/etcd/clientv3"

"github.com/coreos/pkg/capnslog"
"google.golang.org/grpc/grpclog"
)

func init() {
capnslog.SetGlobalLogLevel(capnslog.CRITICAL)
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
clientv3.SetLogger(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
}
2 changes: 2 additions & 0 deletions etcdctl/ctlv3/command/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ func clientConfigFromCmd(cmd *cobra.Command) *clientConfig {
fs.VisitAll(func(f *pflag.Flag) {
fmt.Fprintf(os.Stderr, "%s=%v\n", flags.FlagToEnv("ETCDCTL", f.Name), f.Value)
})
} else {
clientv3.SetLogger(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
}

cfg := &clientConfig{}
Expand Down
4 changes: 3 additions & 1 deletion integration/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package integration
import (
"io/ioutil"

"github.com/coreos/etcd/clientv3"

"github.com/coreos/pkg/capnslog"
"google.golang.org/grpc/grpclog"
)
Expand All @@ -25,5 +27,5 @@ const defaultLogLevel = capnslog.CRITICAL

func init() {
capnslog.SetGlobalLogLevel(defaultLogLevel)
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
clientv3.SetLogger(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
}
3 changes: 2 additions & 1 deletion store/store_v2v3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"io/ioutil"
"testing"

"github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/etcdserver/api/v2v3"
"github.com/coreos/etcd/integration"
"github.com/coreos/etcd/store"
Expand All @@ -30,7 +31,7 @@ import (

func init() {
capnslog.SetGlobalLogLevel(capnslog.CRITICAL)
grpclog.SetLoggerV2(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
clientv3.SetLogger(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
}

type v2v3TestStore struct {
Expand Down

0 comments on commit 02ae7a3

Please sign in to comment.