1
0
Fork 0
forked from github/pelican

Fix dictionary logging in formatter

Python special cases single Mapping arguments to logging. This
adjusts BaseFormatter to skip "fancy" formatting if argument
is of type Mapping. Also adds various formatted log outputs.
This commit is contained in:
Deniz Turgut 2020-05-09 19:39:54 +03:00
commit 50281c42e5
No known key found for this signature in database
GPG key ID: 87B7168D7AB3ED2F
3 changed files with 63 additions and 3 deletions

View file

@ -195,6 +195,15 @@ class LogCountHandler(BufferingHandler):
(level is None or l.levelno == level)
])
def count_formatted_logs(self, msg=None, level=None):
return len([
l
for l
in self.buffer
if (msg is None or re.search(msg, self.format(l))) and
(level is None or l.levelno == level)
])
class LoggedTestCase(unittest.TestCase):
"""A test case that captures log messages."""