-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-34844: logging.Formatter enhancement - Ensure styles and fmt matches in logging.Formatter #9703
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
Changes from 17 commits
66bbddf
0eaaf25
f4f6a60
d51e186
cc2cfbd
7c24e46
abd868d
c1359bb
921ba33
8484f29
4c35216
6eee298
aab0c46
59879e9
43c0b34
908c3ec
d73ab3a
ff05742
2664f85
74ca6a2
de1243f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -666,11 +666,26 @@ def configure_formatter(self, config): | |
dfmt = config.get('datefmt', None) | ||
style = config.get('style', '%') | ||
cname = config.get('class', None) | ||
|
||
if not cname: | ||
c = logging.Formatter | ||
else: | ||
c = _resolve(cname) | ||
result = c(fmt, dfmt, style) | ||
|
||
# Identifying if we need to pass in the validate parameter to the formatter | ||
# - The default in logging.Formatter is True, so we won't need to pass in | ||
# if "validate" key is not in the config | ||
use_validate = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, much simpler than my overthinking! But that's not right, because if the user specified IMO you could lose the
Notice my stubborn sticking to single quotes 😉 |
||
if config.get("validate"): | ||
use_validate = True | ||
|
||
# A TypeError would be raised if "validate" key is passed in with a formatter callable | ||
# that does not accept "validate" as a parameter | ||
if use_validate: | ||
result = c(fmt, dfmt, style, config["validate"]) | ||
else: | ||
result = c(fmt, dfmt, style) | ||
|
||
return result | ||
|
||
def configure_filter(self, config): | ||
|
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.
mismatch
->mismatched