mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
Issue #17540: Added style to Formatter configuration by dict.
This commit is contained in:
parent
6d2bc6e80b
commit
28421c6f62
3 changed files with 10 additions and 3 deletions
|
@ -669,7 +669,8 @@ class DictConfigurator(BaseConfigurator):
|
|||
else:
|
||||
fmt = config.get('format', None)
|
||||
dfmt = config.get('datefmt', None)
|
||||
result = logging.Formatter(fmt, dfmt)
|
||||
style = config.get('style', '%')
|
||||
result = logging.Formatter(fmt, dfmt, style)
|
||||
return result
|
||||
|
||||
def configure_filter(self, config):
|
||||
|
@ -691,6 +692,7 @@ class DictConfigurator(BaseConfigurator):
|
|||
|
||||
def configure_handler(self, config):
|
||||
"""Configure a handler from a dictionary."""
|
||||
config_copy = dict(config) # for restoring in case of error
|
||||
formatter = config.pop('formatter', None)
|
||||
if formatter:
|
||||
try:
|
||||
|
@ -714,7 +716,7 @@ class DictConfigurator(BaseConfigurator):
|
|||
try:
|
||||
th = self.config['handlers'][config['target']]
|
||||
if not isinstance(th, logging.Handler):
|
||||
config['class'] = cname # restore for deferred configuration
|
||||
config.update(config_copy) # restore for deferred cfg
|
||||
raise TypeError('target not configured yet')
|
||||
config['target'] = th
|
||||
except Exception as e:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue