Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/logging/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def _install_handlers(cp, formatters):
kwargs = section.get("kwargs", '{}')
kwargs = eval(kwargs, vars(logging))
h = klass(*args, **kwargs)
h.name = hand
if "level" in section:
level = section["level"]
h.setLevel(level)
Expand Down
24 changes: 24 additions & 0 deletions Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,30 @@ def test_logger_disabling(self):
self.apply_config(self.disable_test, disable_existing_loggers=False)
self.assertFalse(logger.disabled)

def test_config_set_handler_names(self):
test_config = """
[loggers]
keys=root

[handlers]
keys=hand1

[formatters]
keys=form1

[logger_root]
handlers=hand1

[handler_hand1]
class=StreamHandler
formatter=form1

[formatter_form1]
format=%(levelname)s ++ %(message)s
"""
self.apply_config(test_config)
self.assertEquals(logging.getLogger().handlers[0].name, 'hand1')

def test_defaults_do_no_interpolation(self):
"""bpo-33802 defaults should not get interpolated"""
ini = textwrap.dedent("""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Now :func:`~logging.config.fileConfig` correcty sets the .name of handlers loaded.