-
Notifications
You must be signed in to change notification settings - Fork 45
Termination and spaces #11
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
Comments
Yes this is intended behavior. The current approach is documented under the colorize_format() method. Basically I decided to implement it like this (the "simple" approach) until someone came up with a use case not covered by the simple approach. And here you are! :-) So consider this a documented implementation detail. If we can find a way to improve this that doesn't break backwards compatibility (at least not in a surprising way) I'm open to changing the implementation. |
An advantage of the current simple approach (from my perspective) is that it's possible to highlight things like Making the current behavior more flexible introduces more decisions to make. For example if the format string contains The following approach might work:
This change in behavior requires real/proper parsing of logging format strings. This isn't impossible to do of course, but it might be a bit tricky to get it right :-). So one the one hand this complicates the library but on the other hand it can guarantee correct behavior (provided that the format string parsing and rewriting is correct of course). In contrast the current approach is kind of dumb but works fine most of the time (it's possible to break it though, I guess). |
Sounds good. Another approach would be to introduce a reset string, that ends the current colouring, or colour parenthesis strings respectively. |
Hi again @con-f-use and sorry for the long silence here. I've just released coloredlogs 10.0 which should fix the issue you reported: coloredlogs is now finally able to properly distinguish formatting directives from their surrounding text, dropping the dependency on whitespace delimiters. |
I'm still seeing a similar issue with coloredlogs 15.0.1. With |
In the present version, colouring of the different fields (
name
,loglevel
,hostname
, etc.) seems to be dependent on placement of white spaces. I.e. if no white spaces are placed between fields, consecutive fields will have the colour of the first in string. Is that intended behaviour? It can be seen using the following code:where two different format strings are used (note the spaces around
levelanme
,name
andprocess
string formatters):The result is something like this (note the color of the
levelname
and the blurredhostname
field):The text was updated successfully, but these errors were encountered: