mirror of
				https://github.com/kubenetworks/kubevpn.git
				synced 2025-10-31 10:46:35 +08:00 
			
		
		
		
	feat: set envoy log dynamic (#125)
* feat: set envoy log level dynamic * feat: set log level
This commit is contained in:
		| @@ -89,6 +89,10 @@ func CmdClone(f cmdutil.Factory) *cobra.Command { | |||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  | 			logLevel := log.ErrorLevel | ||||||
|  | 			if config.Debug { | ||||||
|  | 				logLevel = log.DebugLevel | ||||||
|  | 			} | ||||||
| 			req := &rpc.CloneRequest{ | 			req := &rpc.CloneRequest{ | ||||||
| 				KubeconfigBytes:        string(bytes), | 				KubeconfigBytes:        string(bytes), | ||||||
| 				Namespace:              ns, | 				Namespace:              ns, | ||||||
| @@ -108,7 +112,7 @@ func CmdClone(f cmdutil.Factory) *cobra.Command { | |||||||
| 				IsChangeTargetRegistry: options.IsChangeTargetRegistry, | 				IsChangeTargetRegistry: options.IsChangeTargetRegistry, | ||||||
| 				TransferImage:          transferImage, | 				TransferImage:          transferImage, | ||||||
| 				Image:                  config.Image, | 				Image:                  config.Image, | ||||||
| 				Level:                  int32(log.DebugLevel), | 				Level:                  int32(logLevel), | ||||||
| 			} | 			} | ||||||
| 			cli := daemon.GetClient(false) | 			cli := daemon.GetClient(false) | ||||||
| 			resp, err := cli.Clone(cmd.Context(), req) | 			resp, err := cli.Clone(cmd.Context(), req) | ||||||
|   | |||||||
| @@ -55,6 +55,10 @@ func CmdConnect(f cmdutil.Factory) *cobra.Command { | |||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				return err | 				return err | ||||||
| 			} | 			} | ||||||
|  | 			logLevel := log.ErrorLevel | ||||||
|  | 			if config.Debug { | ||||||
|  | 				logLevel = log.DebugLevel | ||||||
|  | 			} | ||||||
| 			req := &rpc.ConnectRequest{ | 			req := &rpc.ConnectRequest{ | ||||||
| 				KubeconfigBytes:      string(bytes), | 				KubeconfigBytes:      string(bytes), | ||||||
| 				Namespace:            ns, | 				Namespace:            ns, | ||||||
| @@ -68,7 +72,7 @@ func CmdConnect(f cmdutil.Factory) *cobra.Command { | |||||||
| 				TransferImage: transferImage, | 				TransferImage: transferImage, | ||||||
| 				Foreground:    foreground, | 				Foreground:    foreground, | ||||||
| 				Image:         config.Image, | 				Image:         config.Image, | ||||||
| 				Level:         int32(log.DebugLevel), | 				Level:         int32(logLevel), | ||||||
| 			} | 			} | ||||||
| 			// if is foreground, send to sudo daemon server | 			// if is foreground, send to sudo daemon server | ||||||
| 			cli := daemon.GetClient(false) | 			cli := daemon.GetClient(false) | ||||||
|   | |||||||
| @@ -90,6 +90,10 @@ func CmdProxy(f cmdutil.Factory) *cobra.Command { | |||||||
| 			} | 			} | ||||||
| 			// todo 将 doConnect 方法封装?内部使用 client 发送到daemon? | 			// todo 将 doConnect 方法封装?内部使用 client 发送到daemon? | ||||||
| 			cli := daemon.GetClient(false) | 			cli := daemon.GetClient(false) | ||||||
|  | 			logLevel := log.ErrorLevel | ||||||
|  | 			if config.Debug { | ||||||
|  | 				logLevel = log.DebugLevel | ||||||
|  | 			} | ||||||
| 			client, err := cli.Proxy( | 			client, err := cli.Proxy( | ||||||
| 				cmd.Context(), | 				cmd.Context(), | ||||||
| 				&rpc.ConnectRequest{ | 				&rpc.ConnectRequest{ | ||||||
| @@ -104,7 +108,7 @@ func CmdProxy(f cmdutil.Factory) *cobra.Command { | |||||||
| 					SshJump:              sshConf.ToRPC(), | 					SshJump:              sshConf.ToRPC(), | ||||||
| 					TransferImage:        transferImage, | 					TransferImage:        transferImage, | ||||||
| 					Image:                config.Image, | 					Image:                config.Image, | ||||||
| 					Level:                int32(log.DebugLevel), | 					Level:                int32(logLevel), | ||||||
| 					OriginKubeconfigPath: util.GetKubeconfigPath(f), | 					OriginKubeconfigPath: util.GetKubeconfigPath(f), | ||||||
| 				}, | 				}, | ||||||
| 			) | 			) | ||||||
|   | |||||||
| @@ -502,6 +502,10 @@ func (d *Options) doConnect(ctx context.Context, f cmdutil.Factory, conf *util.S | |||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return | 			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, | 		// not needs to ssh jump in daemon, because dev mode will hang up until user exit, | ||||||
| 		// so just ssh jump in client is enough | 		// so just ssh jump in client is enough | ||||||
| 		req := &rpc.ConnectRequest{ | 		req := &rpc.ConnectRequest{ | ||||||
| @@ -516,7 +520,7 @@ func (d *Options) doConnect(ctx context.Context, f cmdutil.Factory, conf *util.S | |||||||
| 			OriginKubeconfigPath: util.GetKubeconfigPath(f), | 			OriginKubeconfigPath: util.GetKubeconfigPath(f), | ||||||
| 			TransferImage:        transferImage, | 			TransferImage:        transferImage, | ||||||
| 			Image:                config.Image, | 			Image:                config.Image, | ||||||
| 			Level:                int32(log.DebugLevel), | 			Level:                int32(logLevel), | ||||||
| 			SshJump:              conf.ToRPC(), | 			SshJump:              conf.ToRPC(), | ||||||
| 		} | 		} | ||||||
| 		cancel = disconnect(ctx, daemonCli) | 		cancel = disconnect(ctx, daemonCli) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 naison
					naison