mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #7674 from gyuho/debug
ctlv3: add '--debug' flag (to enable grpclog)
This commit is contained in:
commit
e1cf766695
@ -19,6 +19,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -44,6 +46,8 @@ type GlobalFlags struct {
|
|||||||
IsHex bool
|
IsHex bool
|
||||||
|
|
||||||
User string
|
User string
|
||||||
|
|
||||||
|
Debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type secureCfg struct {
|
type secureCfg struct {
|
||||||
@ -79,6 +83,14 @@ func initDisplayFromCmd(cmd *cobra.Command) {
|
|||||||
func mustClientFromCmd(cmd *cobra.Command) *clientv3.Client {
|
func mustClientFromCmd(cmd *cobra.Command) *clientv3.Client {
|
||||||
flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags())
|
flags.SetPflagsFromEnv("ETCDCTL", cmd.InheritedFlags())
|
||||||
|
|
||||||
|
debug, derr := cmd.Flags().GetBool("debug")
|
||||||
|
if derr != nil {
|
||||||
|
ExitWithError(ExitError, derr)
|
||||||
|
}
|
||||||
|
if debug {
|
||||||
|
clientv3.SetLogger(log.New(os.Stderr, "grpc: ", 0))
|
||||||
|
}
|
||||||
|
|
||||||
endpoints, err := cmd.Flags().GetStringSlice("endpoints")
|
endpoints, err := cmd.Flags().GetStringSlice("endpoints")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ExitWithError(ExitError, err)
|
ExitWithError(ExitError, err)
|
||||||
|
@ -44,6 +44,7 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.PersistentFlags().StringSliceVar(&globalFlags.Endpoints, "endpoints", []string{"127.0.0.1:2379"}, "gRPC endpoints")
|
rootCmd.PersistentFlags().StringSliceVar(&globalFlags.Endpoints, "endpoints", []string{"127.0.0.1:2379"}, "gRPC endpoints")
|
||||||
|
rootCmd.PersistentFlags().BoolVar(&globalFlags.Debug, "debug", false, "enable client-side debug logging")
|
||||||
|
|
||||||
rootCmd.PersistentFlags().StringVarP(&globalFlags.OutputFormat, "write-out", "w", "simple", "set the output format (fields, json, protobuf, simple, table)")
|
rootCmd.PersistentFlags().StringVarP(&globalFlags.OutputFormat, "write-out", "w", "simple", "set the output format (fields, json, protobuf, simple, table)")
|
||||||
rootCmd.PersistentFlags().BoolVar(&globalFlags.IsHex, "hex", false, "print byte strings as hex encoded strings")
|
rootCmd.PersistentFlags().BoolVar(&globalFlags.IsHex, "hex", false, "print byte strings as hex encoded strings")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user