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 support for overriding color and name for level along with custom levels. #64

Closed
wants to merge 2 commits into from

Conversation

iamsumit
Copy link

@iamsumit iamsumit commented May 15, 2024

This PR adds the support for customizing the custom log level name and color along with option to override the color of existing levels.

resolves #61

@lmittmann
Copy link
Owner

I appreciate the effort, but am not convinced by the API. slog.Level is an alias for int - why use a map from slog.Level to its string representation?

@lmittmann lmittmann closed this May 20, 2024
@iamsumit
Copy link
Author

why use a map from slog.Level to its string representation?

I am not a go expert, and I know that this is not an elegant solution but I don't understand your doubt here? A map key can be any type that is comparable, be it string or integer.

@lmittmann
Copy link
Owner

A map lookup is expensive. The default slog logic is to print LEVEL+N e.g. INFO+1 for "unmapped" level values, but it is not efficient to build a map that maps all values of int to a string.

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.

Custom log level names with color
2 participants