Skip to content

Commit

Permalink
Catch indexing issue in log level conversion
Browse files Browse the repository at this point in the history
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
  • Loading branch information
TheJackiMonster committed May 3, 2022
1 parent 9a4aa31 commit e45314b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions manuskript/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,12 @@ def logFutureExceptions():
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
Expand Down

0 comments on commit e45314b

Please sign in to comment.