forked from qt-creator/qt-creator
Clang Backend: enable Windows debug logging
On Windows the debug messages are not sent to the Windows logger, because a custom Qt message handler was set up. This commit forwards the messages also to the default message handler. Change-Id: I1745a86f72fcc1e48cd52603633fca2f23c8fedf Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -57,8 +57,25 @@ QString processArguments(QCoreApplication &application)
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
static void messageOutput(QtMsgType type, const QMessageLogContext &, const QString &msg)
|
||||
struct MessageHandler {
|
||||
MessageHandler(QtMessageHandler handler)
|
||||
{
|
||||
defaultHandler = qInstallMessageHandler(handler);
|
||||
}
|
||||
|
||||
~MessageHandler()
|
||||
{
|
||||
qInstallMessageHandler(defaultHandler);
|
||||
}
|
||||
|
||||
static QtMessageHandler defaultHandler;
|
||||
};
|
||||
|
||||
QtMessageHandler MessageHandler::defaultHandler = nullptr;
|
||||
|
||||
static void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||
{
|
||||
MessageHandler::defaultHandler(type, context, msg);
|
||||
std::wcout << msg.toStdWString() << std::endl;
|
||||
if (type == QtFatalMsg)
|
||||
abort();
|
||||
@@ -68,7 +85,7 @@ static void messageOutput(QtMsgType type, const QMessageLogContext &, const QStr
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
qInstallMessageHandler(messageOutput);
|
||||
MessageHandler messageHandler(&messageOutput);
|
||||
#endif
|
||||
QCoreApplication::setOrganizationName(QStringLiteral("QtProject"));
|
||||
QCoreApplication::setOrganizationDomain(QStringLiteral("qt-project.org"));
|
||||
|
||||
Reference in New Issue
Block a user