1616import sys
1717import subprocess
1818import yaml
19-
19+ import logging
20+ logger = logging .getLogger (__name__ )
2021
2122inline_help = True
22-
2323registry = load_key_bindings_for_prompt ()
2424completer = KubectlCompleter ()
2525
@@ -102,17 +102,15 @@ def _(event):
102102 KubeConfig .switch_to_next_cluster ()
103103 Kubeshell .clustername , Kubeshell .user , Kubeshell .namespace = KubeConfig .parse_kubeconfig ()
104104 except Exception as e :
105- # TODO: log errors to log file
106- pass
105+ logger .warning ("failed switching clusters" , exc_info = 1 )
107106
108107 @registry .add_binding (Keys .F5 )
109108 def _ (event ):
110109 try :
111110 KubeConfig .switch_to_next_namespace (Kubeshell .namespace )
112111 Kubeshell .clustername , Kubeshell .user , Kubeshell .namespace = KubeConfig .parse_kubeconfig ()
113112 except Exception as e :
114- # TODO: log errors to log file
115- pass
113+ logger .warning ("failed namespace switching" , exc_info = 1 )
116114
117115 @registry .add_binding (Keys .F9 )
118116 def _ (event ):
@@ -141,6 +139,7 @@ def run_cli(self):
141139 def get_title ():
142140 return "kube-shell"
143141
142+ logger .info ("running kube-shell event loop" )
144143 if not os .path .exists (os .path .expanduser ("~/.kube/config" )):
145144 click .secho ('Kube-shell uses ~/.kube/config for server side completion. Could not find ~/.kube/config. '
146145 'Server side completion functionality may not work.' , fg = 'red' , blink = True , bold = True )
@@ -149,8 +148,7 @@ def get_title():
149148 try :
150149 Kubeshell .clustername , Kubeshell .user , Kubeshell .namespace = KubeConfig .parse_kubeconfig ()
151150 except :
152- # TODO: log errors to log file
153- pass
151+ logger .error ("unable to parse ~/.kube/config %s" , exc_info = 1 )
154152 completer .set_namespace (self .namespace )
155153
156154 try :
0 commit comments