summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2024-04-17 12:55:18 (GMT)
committerGitHub <noreply@github.com>2024-04-17 12:55:18 (GMT)
commit6d0bb43232dd6ebc5245daa4fe29f07f815f0bad (patch)
treecfdf65e9ecc342e15395539f0ee1cc5a23f04cf2 /Lib/logging
parentb9b3c455f0293be67a762f653bd22f864d15fe3c (diff)
downloadcpython-6d0bb43232dd6ebc5245daa4fe29f07f815f0bad.zip
cpython-6d0bb43232dd6ebc5245daa4fe29f07f815f0bad.tar.gz
cpython-6d0bb43232dd6ebc5245daa4fe29f07f815f0bad.tar.bz2
gh-117975: Ensure flush level is checked when configuring a logging MemoryHandler. (GH-117976)
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/config.py26
1 files changed, 14 insertions, 12 deletions
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index ea37dd7..860e475 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -761,18 +761,20 @@ class DictConfigurator(BaseConfigurator):
klass = cname
else:
klass = self.resolve(cname)
- if issubclass(klass, logging.handlers.MemoryHandler) and\
- 'target' in config:
- # Special case for handler which refers to another handler
- try:
- tn = config['target']
- th = self.config['handlers'][tn]
- if not isinstance(th, logging.Handler):
- config.update(config_copy) # restore for deferred cfg
- raise TypeError('target not configured yet')
- config['target'] = th
- except Exception as e:
- raise ValueError('Unable to set target handler %r' % tn) from e
+ if issubclass(klass, logging.handlers.MemoryHandler):
+ if 'flushLevel' in config:
+ config['flushLevel'] = logging._checkLevel(config['flushLevel'])
+ if 'target' in config:
+ # Special case for handler which refers to another handler
+ try:
+ tn = config['target']
+ th = self.config['handlers'][tn]
+ if not isinstance(th, logging.Handler):
+ config.update(config_copy) # restore for deferred cfg
+ raise TypeError('target not configured yet')
+ config['target'] = th
+ except Exception as e:
+ raise ValueError('Unable to set target handler %r' % tn) from e
elif issubclass(klass, logging.handlers.QueueHandler):
# Another special case for handler which refers to other handlers
# if 'handlers' not in config: