Skip to content

Conversation

tksm
Copy link
Contributor

@tksm tksm commented Jan 26, 2023

Fixes #139

This PR adds the --verbosity flag to set the log level verbosity of client-go. This feature will be useful when we want to know how stern interacts with a Kubernetes API server in troubleshooting.

The default flag -v of klog conflicted with the short name of --version of stern, so I added it as a new flag.

It works as follows.

$ stern --verbosity 6 --tail 0 deployment/nginx
I0126 09:55:55.675598   61274 loader.go:373] Config loaded from file:  /Users/tkusumi/.kube/config
I0126 09:55:55.677173   61274 cert_rotation.go:137] Starting client certificate rotation controller
I0126 09:55:55.704852   61274 round_trippers.go:553] GET https://127.0.0.1:54663/apis/apps/v1/namespaces/default/deployments/nginx 200 OK in 27 milliseconds
I0126 09:55:55.706159   61274 retrywatcher.go:247] Starting RetryWatcher.
I0126 09:55:55.707653   61274 round_trippers.go:553] GET https://127.0.0.1:54663/api/v1/namespaces/default/pods?labelSelector=app%3Dnginx&watch=true 200 OK in 1 milliseconds
+ nginx-76d6c9b8c-nlqs9 › nginx
+ nginx-76d6c9b8c-bqqdm › nginx
+ nginx-76d6c9b8c-mg7x7 › nginx
I0126 09:55:55.719894   61274 round_trippers.go:553] GET https://127.0.0.1:54663/api/v1/namespaces/default/pods/nginx-76d6c9b8c-bqqdm/log?container=nginx&follow=true&sinceSeconds=172800&tailLines=0 200 OK in 11 milliseconds
I0126 09:55:55.720401   61274 round_trippers.go:553] GET https://127.0.0.1:54663/api/v1/namespaces/default/pods/nginx-76d6c9b8c-nlqs9/log?container=nginx&follow=true&sinceSeconds=172800&tailLines=0 200 OK in 11 milliseconds
I0126 09:55:55.721048   61274 round_trippers.go:553] GET https://127.0.0.1:54663/api/v1/namespaces/default/pods/nginx-76d6c9b8c-mg7x7/log?container=nginx&follow=true&sinceSeconds=172800&tailLines=0 200 OK in 12 milliseconds

@superbrothers superbrothers merged commit 5327626 into stern:master Jan 26, 2023
@tksm tksm deleted the verbosity branch January 26, 2023 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option for verbose logging
2 participants