gh-117975: Ensure flush level is checked when configuring a logging MemoryHandler. (GH-117976)

This commit is contained in:
Vinay Sajip 2024-04-17 13:55:18 +01:00 committed by GitHub
parent b9b3c455f0
commit 6d0bb43232
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 12 deletions

View file

@ -3036,6 +3036,30 @@ class ConfigDictTest(BaseTest):
},
}
config18 = {
"version": 1,
"handlers": {
"console": {
"class": "logging.StreamHandler",
"level": "DEBUG",
},
"buffering": {
"class": "logging.handlers.MemoryHandler",
"capacity": 5,
"target": "console",
"level": "DEBUG",
"flushLevel": "ERROR"
}
},
"loggers": {
"mymodule": {
"level": "DEBUG",
"handlers": ["buffering"],
"propagate": "true"
}
}
}
bad_format = {
"version": 1,
"formatters": {
@ -3522,6 +3546,11 @@ class ConfigDictTest(BaseTest):
h = logging._handlers['hand1']
self.assertEqual(h.formatter.custom_property, 'value')
def test_config18_ok(self):
self.apply_config(self.config18)
handler = logging.getLogger('mymodule').handlers[0]
self.assertEqual(handler.flushLevel, logging.ERROR)
def setup_via_listener(self, text, verify=None):
text = text.encode("utf-8")
# Ask for a randomly assigned port (by using port 0)