Skip to content

More flexible column detection in complex format strings#9

Open
staticglobal wants to merge 2 commits intolaysakura:masterfrom
staticglobal:master
Open

More flexible column detection in complex format strings#9
staticglobal wants to merge 2 commits intolaysakura:masterfrom
staticglobal:master

Conversation

@staticglobal
Copy link

python printf-style format strings, such as those used by the logging
formatter, have provisions for many advanced field conversions such as
field widths, padding characters, etc. For example, you can force the
"msecs" to always be a zero-padded 3-digit field by specifying
"%(msecs)03d". However, modifiers such as these breaks
rainbow_logging_handler which is looking for a strict string match for
"%(msecs)d".

This change enhances rainbow_logging_handler to detect and cope with
(almost) any field conversion modifiers and still apply the appropriate
colors.

python printf-style format strings, such as those used by the logging
formatter, have provisions for many advanced field conversions such as
field widths, padding characters, etc.  For example, you can force the
"msecs" to always be a zero-padded 3-digit field by specifying
"%(msecs)03d".  However, modifiers such as these breaks
rainbow_logging_handler which is looking for a strict string match for
"%(msecs)d".

This change enhances rainbow_logging_handler to detect and cope with
(almost) any field conversion modifiers and still apply the appropriate
colors.
@staticglobal
Copy link
Author

Also adds a new dependency on the "re" standard library

@miohtama
Copy link
Collaborator

Hi!

I am taking over the library maintenance. Can you please add an automated test case to stress out this functonality and it's good to merge.

@jclosure
Copy link

+1 - for this feature. The current date stamp format doesn't support the ms precision we need.

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.

3 participants