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

Feature: colorize logs #51

Closed
applejag opened this issue Jan 26, 2024 · 3 comments · Fixed by #157
Closed

Feature: colorize logs #51

applejag opened this issue Jan 26, 2024 · 3 comments · Fixed by #157
Labels
enhancement New feature or request

Comments

@applejag
Copy link
Collaborator

Expected Behavior

Would be grand if kubecolor could do some simple colorizing of log lines when doing kubecolor logs my-pod-123.

Could be a lot of simple colorizing techniques, such as highlighting ERROR, ERR, and ERRO as bold red. Have WARNING, WRN, and WARN as orange/dark yellow, and so on.

As well as colorizing quotations "text" or stuff inside square brackets [text] to make them stand out more.

It's not a perfect solution, but it could help find some keywords in logs.

Then if the log line is a JSON or logfmt message, then apply syntax highlighting there as well. Such as in JSON to highlight the key vs value parts.

Also think timestamps should be grayed out, like using "bright black" in basic ANSI terminal coloring terms.

Current Behavior

Logs are just green.

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

  • Operating System: Linux
  • kubectl version:
  • kubecolor version: v0.2.2
@applejag applejag added the enhancement New feature or request label Jan 26, 2024
@semihbkgr
Copy link
Contributor

semihbkgr commented Mar 3, 2024

Hi @applejag

moving from #70 🙂

As you explained, there are many ways to enhance log colorization. However, it's crucial to check first if the logs are already colored. This is an additional detail I explained in #70

@prune998
Copy link
Contributor

Well, I think we should just not colorize any logs at all. I guess the green coloring is a bug and we can correct it.

There's this wonderful application called Stern (https://github.com/stern/stern) that will do log coloring better and will handle all the use-cases.
Any PR will be welcome but it's the feature with the least priority on my list :)

@applejag
Copy link
Collaborator Author

I think this could be fun to tackle. :)

Besides, I see that Stern is written in Go, so maybe we could import Stern as a dependency? I don't see much coloring logic in the Stern source code though of the logs themselves.

Their README is also lacking screenshots sadly. @prune998 Do you happen to have a screenshot of Stern coloring the output? Could spark inspiration :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants