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
Support bg+fg for log_color/log_message_color #17
Conversation
- Added option for log_message_color, which (like log_color) is intended to provide debug level specific coloring for the message - Added support for simultaneous fg and bg color settings in log_color/log_message_color usage: log_colors={„DEBUG“: „fg_white bg_red“}
Initial thoughts - I'm not very clear on what |
I like the idea of supporting |
@initial thoughts: Basically whenever I log something, that line has to parts:
I am not exactly sure what you are getting at in the other comment. The problem here was that you explicitly parsed the color_name. Anywhere else you would just do a %(bg_blue)s%(white)s, or am I missing something? |
Right, okay :)
The approach I'm considering is this, letting a user have any number of alternate mappings. ColoredFormatter(
"%(log_color)s%(levelname)-8s%(reset)s %(log_color_message)s%(message)s",
alternate_log_colors={
'message': {
'DEBUG': 'blue',
...
}
}
}
Correct - though what I'd like to do is allow any color spec to use multiple codes (which could include other codes like bold or underline). So you could have I'm happy to merge this and adapt it - my primary concern is getting the API of any new features right 😄 |
Yes, I already had similar code in mind. I was actually about to start a new project and thought 'A little coloring would be nice for the output'. That is when I came across your project. I loved the debug level specific coloring, but being a bit color blind, I needed the bg/fg combination to see a difference on the first glance.
Basically you want the format string to be cleaner (%(white,bg_blue)s is aquivalent to %(white)s&%(bg_blue)s).
I absolutely agree with you there..but it is sometimes just so hard to predict where a project might go in the future and what will be needed. |
Okay, I'll start work on adapting this once I'm at my dev machine 😄
Basically, records are formatted with something like |
This has been merged into the develop branch. An explaination of the new format is here: Using secondary log colors. Any comments before this is released? |
looks good from a quick glance! Maybe an example for using multiple codes with the ',' would be nice? |
Thanks, missed that :) I'll add an example tomorrow! |
Enhancement
intended to provide debug level specific coloring for the message (set via log_message_colors in init)
log_color/log_message_color by appending another code after a single whitspace
example: