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>
This commit is contained in:
parent
7ec9813490
commit
fe5ba70e55
@ -1371,7 +1371,7 @@ static bool slog2_default_handler(QtMsgType type, const QMessageLogContext &cont
|
|||||||
//writes to the slog2 buffer
|
//writes to the slog2 buffer
|
||||||
slog2c(NULL, QT_LOG_CODE, severity, formattedMessage.toLocal8Bit().constData());
|
slog2c(NULL, QT_LOG_CODE, severity, formattedMessage.toLocal8Bit().constData());
|
||||||
|
|
||||||
return false;
|
return true; // Prevent further output to stderr
|
||||||
}
|
}
|
||||||
#endif // slog2
|
#endif // slog2
|
||||||
|
|
||||||
@ -1561,7 +1561,7 @@ static bool systemd_default_message_handler(QtMsgType type,
|
|||||||
"QT_CATEGORY=%s", context.category ? context.category : "unknown",
|
"QT_CATEGORY=%s", context.category ? context.category : "unknown",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
return false;
|
return true; // Prevent further output to stderr
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1594,7 +1594,7 @@ static bool syslog_default_message_handler(QtMsgType type, const QMessageLogCont
|
|||||||
|
|
||||||
syslog(priority, "%s", formattedMessage.toUtf8().constData());
|
syslog(priority, "%s", formattedMessage.toUtf8().constData());
|
||||||
|
|
||||||
return false;
|
return true; // Prevent further output to stderr
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1621,7 +1621,7 @@ static bool android_default_message_handler(QtMsgType type,
|
|||||||
"%s:%d (%s): %s\n", context.file, context.line,
|
"%s:%d (%s): %s\n", context.file, context.line,
|
||||||
context.function, qPrintable(formattedMessage));
|
context.function, qPrintable(formattedMessage));
|
||||||
|
|
||||||
return false;
|
return true; // Prevent further output to stderr
|
||||||
}
|
}
|
||||||
#endif //Q_OS_ANDROID
|
#endif //Q_OS_ANDROID
|
||||||
|
|
||||||
@ -1634,7 +1634,8 @@ static bool win_message_handler(QtMsgType type, const QMessageLogContext &contex
|
|||||||
QString formattedMessage = qFormatLogMessage(type, context, message);
|
QString formattedMessage = qFormatLogMessage(type, context, message);
|
||||||
formattedMessage.append(QLatin1Char('\n'));
|
formattedMessage.append(QLatin1Char('\n'));
|
||||||
OutputDebugString(reinterpret_cast<const wchar_t *>(formattedMessage.utf16()));
|
OutputDebugString(reinterpret_cast<const wchar_t *>(formattedMessage.utf16()));
|
||||||
return false;
|
|
||||||
|
return true; // Prevent further output to stderr
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user