From d4fd9d9ae801f6eecc1e355b1bd4fcbbaaf02916 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 24 May 2023 10:20:52 +0200 Subject: [PATCH] Gui: also print category string of Qt messages --- src/Gui/Application.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 07848d0a8a..b124a44e64 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -1753,26 +1753,35 @@ _qt_msg_handler_old old_qtmsg_handler = nullptr; void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg) { - Q_UNUSED(context); + QByteArray output; + if (context.category && strcmp(context.category, "default") != 0) { + output.append('('); + output.append(context.category); + output.append(')'); + output.append(' '); + } + + output.append(msg.toUtf8()); + switch (type) { case QtInfoMsg: case QtDebugMsg: #ifdef FC_DEBUG - Base::Console().Message("%s\n", msg.toUtf8().constData()); + Base::Console().Message("%s\n", output.constData()); #else // do not stress user with Qt internals but write to log file if enabled - Base::Console().Log("%s\n", msg.toUtf8().constData()); + Base::Console().Log("%s\n", output.constData()); #endif break; case QtWarningMsg: - Base::Console().Warning("%s\n", msg.toUtf8().constData()); + Base::Console().Warning("%s\n", output.constData()); break; case QtCriticalMsg: - Base::Console().Error("%s\n", msg.toUtf8().constData()); + Base::Console().Error("%s\n", output.constData()); break; case QtFatalMsg: - Base::Console().Error("%s\n", msg.toUtf8().constData()); + Base::Console().Error("%s\n", output.constData()); abort(); // deliberately core dump } #ifdef FC_OS_WIN32