QMessageHandler¶
A context manager that captures the messages that Qt logs (with qDebug,
qWarning, qCritical, and so on), instead of printing them, for example to
check for them in tests, or to send them to Python's logging.
QMessageHandler
¶
QMessageHandler(logger: Logger | None = None)
A context manager to intercept messages from Qt.
Parameters:
-
logger(Logger, default:None) –If provided, intercepted messages will be logged with
loggerat the corresponding python log level, by default None
Attributes:
-
records(list of tuple) –Captured messages. This is a 3-tuple of:
(log_level: int, message: str, context: dict)
Examples:
>>> handler = QMessageHandler()
>>> handler.install() # now all Qt output will be available at mh.records