-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix non-%
-style formatting
#23
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you for your pull request.
Could you add a test case to make sure that the '{' formatting is working?
You could refer to the existing one to make your test case.
I'm using pytest
and the test runs from the .\tests
folder.
Sure, shall do. That being said, I'm hitting problems still. In particular, the 'automagicially'-instantiated root logger is instantiated in the import, which is necessarily before the call to |
In other words, this knocks down the first hurdle, not everything. |
Ah. The QueueHandler is always using the default formatter. Let me see if I can fix that... |
As it turns out, It purely affects the style of the format string passed to the formatter, not the format of the log message itself. There are still some fixes required for this to work - that I'll push in a few minutes along with an associated test - but looks like I'll still need to do my 'usual' wrapper to make |
|
Skipped tests were:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your added code. Just a little change is needed before we can merge.
@@ -386,7 +387,7 @@ def _standardize(self, fmt): | |||
formatters = {'normal': fmt.replace(self.default_formats['normal'][0], self.default_formats['normal'][1])} | |||
|
|||
# concurrent format | |||
concurrent_fmt = formatters['normal'].replace('%(threadName)s', '').replace('%(processName)s', '') | |||
concurrent_fmt = formatters['normal'].replace('%(threadName)s', '').replace('%(processName)s', '').replace('{threadName}', '').replace('{processName}', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, this line is too long. Can you split it into two lines?
concurrent_fmt = formatters['normal'].replace('%(threadName)s', '').replace('%(processName)s', '')
concurrent_fmt = concurrent_fmt .replace('{threadName}', '').replace('{processName}', '')
@@ -125,6 +125,7 @@ def _replace_with_queue_handler(self): | |||
# add queue handler | |||
queue = self.qclass() | |||
q_handler = handlers.QueueHandler(queue) | |||
q_handler.setFormatter(all_handlers[0].formatter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we assume that all handlers use the same formatter.
It may not be always correct but let's just go with it for now.
I'll make a note in the README later.
I dug into #22 a little, and it appears as though the problem is here:
Note that the initial super() call does not pass along
style
, but then it passes the samefmt
into the underlyinglogging.Formatters
withstyle
. Then then results in the same format string being interpreted as%
-style and{
-style in different places.