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
paris: use a paris also for write_level #87
Conversation
If we are using paris feature to have a colored terminal (and log), then it is also nice to have a levels colored in the log as well. This way one can easily view created log in a similar look (with colors) as it is printed real-time on a terminal. Tip: To view the log with colors using 'less' you can use: less -R /path/to/log
I think colored log levels are in general a good idea, but I do not think that this feature should require So I would rather like to see an implementation for |
I see. Don't you mean an implementation for I have to see if methods like: |
Yes of course, |
@Drakulix |
@Drakulix
I think that plain paris API is much simpler in its color formatter implementation for this purpose and as well as amount of source code added to get this goal... My introduced function termcolor_to_paris should also cover the custom color configuration for specific log levels in simplelog config. |
Alright, I have given this some more thought. So it seems, you are right and The reason I did not want to depend on paris for this feature is, that this implementation is quite inefficient, because it needs to allocate a If users actively choose to use paris for their log messages, that is not really my (or rather simplelog's problem), which is why I was fine with the paris-macros in the first place. If you choose to use paris, you get worse performance in exchange for a fancy feature, which might be fine depending on the amount of logging you are doing. But this feels a lot more implicit. I expect more users to want colored levels in their log files (although this is highly unix-dependent), then to straight up integrate with paris. And for them this trade-off is not very explicit, because that paris is used in the background to produce the colored levels is mostly an implementation detail. And for high-volume logging this will definitely make a difference and would be very much unexpected for a "simple logging library". So this leaves us with two options:
We cannot instead replace I am not really stoked to do either, but I will make this dependant on the amount of work, you are willing to put in:
In any way, this needs to have an additional config toggle. Something like |
Ah - stupid github - I renamed a branch and it closed my PR instead of leaving it open... |
Hi Victor,
I've prepared another PR:
And then I can easily scroll back/see my program log as in terminal and the log level colors are doing its job: