Qt: Print qDebug messages by default.

We handle Qt and GLib logging in the same handler, which means that if
we map qDebug messages to G_LOG_LEVEL_DEBUG they won't be printed by
default. This can make debugging the UI more confusing, since sprinkling
in qDebug()s is a common Qt debugging method. If you're focused on
fixing a bug it's easy to forget that you need to use qWarning() or
change the logging level preference instead.

Set the log level for qDebug messages to G_LOG_LEVEL_WARNING so that
they show up.

Change-Id: I4336b001cb667a31bf8b25306cd34e758cc8967e
Reviewed-on: https://code.wireshark.org/review/34937
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Gerald Combs 2019-11-03 16:47:18 +00:00 committed by Roland Knall
parent 26504a0024
commit f2036f0fbd

View File

@ -308,14 +308,13 @@ g_log_message_handler(QtMsgType type, const QMessageLogContext &, const QString
GLogLevelFlags log_level = G_LOG_LEVEL_DEBUG;
switch (type) {
case QtDebugMsg:
default:
break;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0))
case QtInfoMsg:
log_level = G_LOG_LEVEL_INFO;
break;
#endif
// We want qDebug() messages to show up at our default log level.
case QtDebugMsg:
case QtWarningMsg:
log_level = G_LOG_LEVEL_WARNING;
break;
@ -325,6 +324,8 @@ g_log_message_handler(QtMsgType type, const QMessageLogContext &, const QString
case QtFatalMsg:
log_level = G_LOG_FLAG_FATAL;
break;
default:
break;
}
g_log(LOG_DOMAIN_MAIN, log_level, "%s", qUtf8Printable(msg));
}