Created
August 28, 2019 13:53
-
-
Save Denzilb55/f46f2e60d84f81bd9791ec137a3d656b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const QtMessageHandler QT_DEFAULT_MESSAGE_HANDLER = qInstallMessageHandler(0); | |
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg) | |
{ | |
QString categoryString = QString(context.category); | |
if (categoryString.compare("default") == 0 || categoryString.compare("qml") == 0) { | |
switch (type) { | |
case QtDebugMsg: | |
qCDebug(category) << msg; | |
break; | |
case QtWarningMsg: | |
qCWarning(category) << msg; | |
break; | |
case QtCriticalMsg: | |
qCCritical(category) << msg; | |
break; | |
case QtFatalMsg: | |
qCFatal(category) << msg; | |
break; | |
} | |
} | |
else { | |
(*QT_DEFAULT_MESSAGE_HANDLER)(type, context, msg + categoryString); | |
if (type == QtFatalMsg) { | |
abort(); | |
} | |
} | |
} | |
int main(int argc, char* argv[]) | |
{ | |
qInstallMessageHandler(messageHandler); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment