From e45314ba2d3c58287255c44cf9fd1db7bf697c49 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Tue, 3 May 2022 14:10:37 +0200 Subject: [PATCH] Catch indexing issue in log level conversion Signed-off-by: TheJackiMonster --- manuskript/logging.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/manuskript/logging.py b/manuskript/logging.py index cced038..5555e73 100644 --- a/manuskript/logging.py +++ b/manuskript/logging.py @@ -218,10 +218,12 @@ from PyQt5.Qt import QtMsgType def qtMessageHandler(msg_type, msg_log_context, msg_string): """Forwards Qt messages to Python logging system.""" # Convert Qt msg type to logging level - log_level = [logging.DEBUG, - logging.WARNING, - logging.ERROR, - logging.FATAL] [ int(msg_type) ] + msg_type_index = int(msg_type) + log_levels = [logging.DEBUG, logging.INFO, logging.WARNING, logging.ERROR, logging.FATAL] + if (msg_type_index >= 0) and (msg_type_index < len(log_levels)): + log_level = log_levels[msg_type_index] + else: + log_level = log_levels[-1] qtcl = logging.getLogger(msg_log_context.category or "qt.???") # Some information may not be available unless using a PyQt debug build. # See: https://www.riverbankcomputing.com/static/Docs/PyQt5/api/qtcore/qmessagelogcontext.html