bpo-34844: logging.Formatter enhancement - Ensure style and format string matches in logging.Formatter (GH-9703)
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index fa1a398..cfd9311 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -666,11 +666,19 @@
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)
+
+ # A TypeError would be raised if "validate" key is passed in with a formatter callable
+ # that does not accept "validate" as a parameter
+ if 'validate' in config: # if user hasn't mentioned it, the default will be fine
+ result = c(fmt, dfmt, style, config['validate'])
+ else:
+ result = c(fmt, dfmt, style)
+
return result
def configure_filter(self, config):