1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
import logging
class AsyncioErrors(AssertionError):
def __repr__(self):
# pylint: disable=unsubscriptable-object
return f"<AsyncioErrors: Got asyncio errors: {self.args[0]!r}"
class Handler(logging.Handler):
def __init__(self):
super().__init__(level=logging.ERROR)
self.messages = []
def emit(self, record):
message = record.msg % record.args
self.messages.append(message)
asyncio_logger = logging.getLogger('asyncio')
handler = Handler()
asyncio_logger.addHandler(handler)
|