diff --git a/cmd/kubevpn/cmds/clone.go b/cmd/kubevpn/cmds/clone.go index eccaf78d..eed850c0 100644 --- a/cmd/kubevpn/cmds/clone.go +++ b/cmd/kubevpn/cmds/clone.go @@ -89,6 +89,10 @@ func CmdClone(f cmdutil.Factory) *cobra.Command { if err != nil { return err } + logLevel := log.ErrorLevel + if config.Debug { + logLevel = log.DebugLevel + } req := &rpc.CloneRequest{ KubeconfigBytes: string(bytes), Namespace: ns, @@ -108,7 +112,7 @@ func CmdClone(f cmdutil.Factory) *cobra.Command { IsChangeTargetRegistry: options.IsChangeTargetRegistry, TransferImage: transferImage, Image: config.Image, - Level: int32(log.DebugLevel), + Level: int32(logLevel), } cli := daemon.GetClient(false) resp, err := cli.Clone(cmd.Context(), req) diff --git a/cmd/kubevpn/cmds/connect.go b/cmd/kubevpn/cmds/connect.go index afc8fadf..66c3cb4d 100644 --- a/cmd/kubevpn/cmds/connect.go +++ b/cmd/kubevpn/cmds/connect.go @@ -55,6 +55,10 @@ func CmdConnect(f cmdutil.Factory) *cobra.Command { if err != nil { return err } + logLevel := log.ErrorLevel + if config.Debug { + logLevel = log.DebugLevel + } req := &rpc.ConnectRequest{ KubeconfigBytes: string(bytes), Namespace: ns, @@ -68,7 +72,7 @@ func CmdConnect(f cmdutil.Factory) *cobra.Command { TransferImage: transferImage, Foreground: foreground, Image: config.Image, - Level: int32(log.DebugLevel), + Level: int32(logLevel), } // if is foreground, send to sudo daemon server cli := daemon.GetClient(false) diff --git a/cmd/kubevpn/cmds/proxy.go b/cmd/kubevpn/cmds/proxy.go index c0223057..573987d4 100644 --- a/cmd/kubevpn/cmds/proxy.go +++ b/cmd/kubevpn/cmds/proxy.go @@ -90,6 +90,10 @@ func CmdProxy(f cmdutil.Factory) *cobra.Command { } // todo 将 doConnect 方法封装?内部使用 client 发送到daemon? cli := daemon.GetClient(false) + logLevel := log.ErrorLevel + if config.Debug { + logLevel = log.DebugLevel + } client, err := cli.Proxy( cmd.Context(), &rpc.ConnectRequest{ @@ -104,7 +108,7 @@ func CmdProxy(f cmdutil.Factory) *cobra.Command { SshJump: sshConf.ToRPC(), TransferImage: transferImage, Image: config.Image, - Level: int32(log.DebugLevel), + Level: int32(logLevel), OriginKubeconfigPath: util.GetKubeconfigPath(f), }, ) diff --git a/pkg/dev/main.go b/pkg/dev/main.go index 56b7d19a..06e8240a 100644 --- a/pkg/dev/main.go +++ b/pkg/dev/main.go @@ -502,6 +502,10 @@ func (d *Options) doConnect(ctx context.Context, f cmdutil.Factory, conf *util.S if err != nil { return } + logLevel := log.ErrorLevel + if config.Debug { + logLevel = log.DebugLevel + } // not needs to ssh jump in daemon, because dev mode will hang up until user exit, // so just ssh jump in client is enough req := &rpc.ConnectRequest{ @@ -516,7 +520,7 @@ func (d *Options) doConnect(ctx context.Context, f cmdutil.Factory, conf *util.S OriginKubeconfigPath: util.GetKubeconfigPath(f), TransferImage: transferImage, Image: config.Image, - Level: int32(log.DebugLevel), + Level: int32(logLevel), SshJump: conf.ToRPC(), } cancel = disconnect(ctx, daemonCli)