2013-11-10 21:52:01 +00:00
|
|
|
#include "IgnoreDebugOutput.h"
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QString>
|
2013-12-24 23:42:28 +00:00
|
|
|
#include <stdio.h>
|
2013-11-10 21:52:01 +00:00
|
|
|
|
|
|
|
void debugIgnoringMessageHandler(QtMsgType type, const char *msg);
|
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
void debugIgnoringMessageHandlerQt5(QtMsgType type, const QMessageLogContext &context, const QString &message);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void debugIgnoringMessageHandler(QtMsgType type, const char *msg) {
|
|
|
|
switch (type) {
|
|
|
|
case QtDebugMsg:
|
|
|
|
case QtWarningMsg:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
fprintf(stderr, "%s\n", msg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
void debugIgnoringMessageHandlerQt5(QtMsgType type, const QMessageLogContext &context, const QString &message) {
|
|
|
|
Q_UNUSED(context);
|
|
|
|
debugIgnoringMessageHandler(type, message.toLocal8Bit().data());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void ignoreDebugOutput(void) {
|
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
|
|
|
|
qInstallMessageHandler(debugIgnoringMessageHandlerQt5);
|
|
|
|
#else
|
|
|
|
qInstallMsgHandler(debugIgnoringMessageHandler);
|
|
|
|
#endif
|
|
|
|
}
|