mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
gh-117975: Ensure flush level is checked when configuring a logging MemoryHandler. (GH-117976)
This commit is contained in:
parent
b9b3c455f0
commit
6d0bb43232
2 changed files with 43 additions and 12 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue