feat: set envoy log dynamic (#125)

* feat: set envoy log level dynamic

* feat: set log level
This commit is contained in:
naison
2024-01-12 10:47:49 +08:00
committed by GitHub
parent e2cb639c6e
commit 8c55d39af2
4 changed files with 20 additions and 4 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -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),
},
)

View File

@@ -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)