Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added output modes to colorize json output #190

Merged
merged 3 commits into from
Sep 26, 2022

Conversation

prune998
Copy link
Contributor

@prune998 prune998 commented Sep 23, 2022

This PR is about adding two new output modes to Stern:

  • extjson is an extended json mode where the whole output is embeded in json and the namespace/pod/container values are color-coded as in the default mode.
  • ppextjson is the same as the above with pretty-print, so each field is on its own line.

Both of those modes can be piped into jq if you want full pretty-print, but you'll lose the original color-coding.

I think those options are usefull when you're dealing with Json structured logs. It helps visializing the informations without being too intrusive.
It's better than using the raw output or raw | jq '.' as pretty-printing the whole log line can quickly fill the console if you have lots of logs.

It's not a revolution but I guess it does not hurt to add this feature :)

ex:

./stern_cli nodepool-labeler-controller-manager --tail 2  --all-namespaces --output extjson -c manager

./stern_cli nodepool-labeler-controller-manager --tail 2  --all-namespaces --output extjson -c manager | jq '.'

./stern_cli nodepool-labeler-controller-manager --tail 2  --all-namespaces --output ppextjson -c manager

__stern_cli_nodepool-labeler-controller-manager_--tail_2_--all-namespaces___-_and_prune_nas____and_cli_go_—_stern

__stern_cli_nodepool-labeler-controller-manager_--tail_2_--all-namespaces___-

__stern_cli_nodepool-labeler-controller-manager_--tail_2_--all-namespaces___-_and_prune_nas___

Copy link
Member

@rkmathi rkmathi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prune998
Thank you for your implementation!
I think this feature is very useful.

@superbrothers @floryut
What do you think?

cmd/cmd.go Outdated Show resolved Hide resolved
cmd/cmd.go Outdated Show resolved Hide resolved
Copy link
Member

@floryut floryut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prune998 Thank you for your implementation! I think this feature is very useful.

@superbrothers @floryut What do you think?

Great! Thank you for your contrib @prune998
please review @superbrothers comments 👍

@prune998
Copy link
Contributor Author

All done ! Please merge if you think it's ready !

Many thanks all for supporting Stern !

@superbrothers superbrothers merged commit 3798ef5 into stern:master Sep 26, 2022
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.

None yet

4 participants