Conversation
deankarn
left a comment
There was a problem hiding this comment.
First off, TY for taking the time for making a PR to improve this library.
Unfortunately I won't be able to merge this. This change assumes that all handlers may be interesting in coloured output, but in reality almost that's exclusive to logging within the terminal.
Color or other options like this should be the responsibility of each handler itself to keep the logging library agnostic. Also I'm not sure I'm sold on the whole line being coloured vs the key information(where you want your eye to be drawn to).
I used to have a coloured output option logger in v7 of this library here. I'd be willing to re-add this alongside the existing json logger to the built-in handlers again(with a few minor tweaks) and optional colour based on terminal detection in the default logger :)
The only issue is that I'm very busy at the moment and won't be able to find the time for at least 3 weeks, maybe more.
Levels Colorization
This pull request adds colorization support for log levels in the logging package. Each log level is assigned a specific color based on its string representation, providing improved visual distinction for log entries.
Changes Made
ColorizeLevelfunction.DefaultColor,DebugColor,InfoColor, etc.).Colorinterface and added corresponding methods to retrieve the ANSI escape codes for each color.PrintColorfunction to set the appropriate color for the log level and print it.Usage
To use the colorized log levels, simply call the
ColorizeLevelfunction and pass the log level as an argument. For example:Example of output:
