mirror of
https://github.com/python/cpython.git
synced 2025-08-09 11:29:45 +00:00
[3.12] gh-117975: Ensure flush level is checked when configuring a logging MemoryHandler. (GH-117976) (GH-117986)
(cherry picked from commit 6d0bb43232
)
This commit is contained in:
parent
c270caf966
commit
2b68c81283
2 changed files with 43 additions and 12 deletions
|
@ -3050,6 +3050,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": {
|
||||
|
@ -3536,6 +3560,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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue