*: use grpclog.NewLoggerV2

Signed-off-by: Gyu-Ho Lee <gyuhox@gmail.com>
This commit is contained in:
Gyu-Ho Lee 2017-11-16 05:44:50 -08:00
parent d62e39d5ca
commit 2a6d50470d
3 changed files with 9 additions and 5 deletions

View File

@ -19,7 +19,6 @@ import (
"errors" "errors"
"io" "io"
"io/ioutil" "io/ioutil"
"log"
"os" "os"
"strings" "strings"
"time" "time"
@ -29,6 +28,7 @@ import (
"github.com/coreos/etcd/pkg/flags" "github.com/coreos/etcd/pkg/flags"
"github.com/coreos/etcd/pkg/transport" "github.com/coreos/etcd/pkg/transport"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"google.golang.org/grpc/grpclog"
) )
// GlobalFlags are flags that defined globally // GlobalFlags are flags that defined globally
@ -88,7 +88,9 @@ func mustClientFromCmd(cmd *cobra.Command) *clientv3.Client {
ExitWithError(ExitError, derr) ExitWithError(ExitError, derr)
} }
if debug { if debug {
clientv3.SetLogger(log.New(os.Stderr, "grpc: ", 0)) clientv3.SetLogger(grpclog.NewLoggerV2WithVerbosity(os.Stderr, os.Stderr, os.Stderr, 4))
} else {
clientv3.SetLogger(grpclog.NewLoggerV2(ioutil.Discard, ioutil.Discard, ioutil.Discard))
} }
endpoints, err := cmd.Flags().GetStringSlice("endpoints") endpoints, err := cmd.Flags().GetStringSlice("endpoints")

View File

@ -17,13 +17,14 @@ package cmd
import ( import (
"crypto/rand" "crypto/rand"
"fmt" "fmt"
"log"
"os" "os"
"strings" "strings"
"github.com/coreos/etcd/clientv3" "github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/pkg/report" "github.com/coreos/etcd/pkg/report"
"golang.org/x/net/context" "golang.org/x/net/context"
"google.golang.org/grpc/grpclog"
) )
var ( var (
@ -98,7 +99,7 @@ func mustCreateConn() *clientv3.Client {
return mustCreateConn() return mustCreateConn()
} }
clientv3.SetLogger(log.New(os.Stderr, "grpc", 0)) clientv3.SetLogger(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr))
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "dial error: %v\n", err) fmt.Fprintf(os.Stderr, "dial error: %v\n", err)

View File

@ -16,6 +16,7 @@ package main
import ( import (
"fmt" "fmt"
"os"
"strings" "strings"
"sync" "sync"
"time" "time"
@ -24,7 +25,7 @@ import (
"google.golang.org/grpc/grpclog" "google.golang.org/grpc/grpclog"
) )
func init() { grpclog.SetLogger(plog) } func init() { grpclog.SetLoggerV2(grpclog.NewLoggerV2(os.Stderr, os.Stderr, os.Stderr)) }
type Stresser interface { type Stresser interface {
// Stress starts to stress the etcd cluster // Stress starts to stress the etcd cluster