diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-02-07 14:31:19 +0100 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2018-02-08 16:59:17 +0000 |
commit | fe5ba70e5571b75060e52973c5c96c77055a1794 (patch) | |
tree | 8de7a0a8672b988166bcea86db622d9f1211916e /src/corelib/global/qlogging.cpp | |
parent | 7ec98134902de9afce51c66e8c252e004f5891b1 (diff) |
Prevent duplicated log output when using alternate logging sinks
3d02e75c07f was too quick, and didn't account for the fact that the
old code had early returns for each alternate logging sink, so when
removing the qt_logging_to_console() check, we would end up writing
debug output twice.
This is due to e.g. Qt Creator running the application without a
console, so qt_logging_to_console() returns false, so we end up
in e.g. the win_message_handler(), calling OutputDebugString,
but then we unconditionally print to stderr, which Creator
also reads, so we end up with duplicated log messages.
Change-Id: I91573828576608643477ae27d36d7e819f92985d
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r-- | src/corelib/global/qlogging.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index e2d08544a1..bad13a70b5 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -1371,7 +1371,7 @@ static bool slog2_default_handler(QtMsgType type, const QMessageLogContext &cont //writes to the slog2 buffer slog2c(NULL, QT_LOG_CODE, severity, formattedMessage.toLocal8Bit().constData()); - return false; + return true; // Prevent further output to stderr } #endif // slog2 @@ -1561,7 +1561,7 @@ static bool systemd_default_message_handler(QtMsgType type, "QT_CATEGORY=%s", context.category ? context.category : "unknown", NULL); - return false; + return true; // Prevent further output to stderr } #endif @@ -1594,7 +1594,7 @@ static bool syslog_default_message_handler(QtMsgType type, const QMessageLogCont syslog(priority, "%s", formattedMessage.toUtf8().constData()); - return false; + return true; // Prevent further output to stderr } #endif @@ -1621,7 +1621,7 @@ static bool android_default_message_handler(QtMsgType type, "%s:%d (%s): %s\n", context.file, context.line, context.function, qPrintable(formattedMessage)); - return false; + return true; // Prevent further output to stderr } #endif //Q_OS_ANDROID @@ -1634,7 +1634,8 @@ static bool win_message_handler(QtMsgType type, const QMessageLogContext &contex QString formattedMessage = qFormatLogMessage(type, context, message); formattedMessage.append(QLatin1Char('\n')); OutputDebugString(reinterpret_cast<const wchar_t *>(formattedMessage.utf16())); - return false; + + return true; // Prevent further output to stderr } #endif |