Last active
March 16, 2016 00:41
-
-
Save ricardodovalle/5915633 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
#include <QApplication> | |
#include <QDebug> | |
void messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) | |
{ | |
QByteArray localMsg = msg.toUtf8(); | |
switch (type) { | |
case QtDebugMsg: | |
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); | |
break; | |
case QtWarningMsg: | |
fprintf(stderr, "Warni: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); | |
break; | |
case QtCriticalMsg: | |
fprintf(stderr, "Criti: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); | |
break; | |
case QtFatalMsg: | |
fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); | |
abort(); | |
} | |
fflush(stderr); | |
} | |
int main(int argc, char *argv[]) | |
{ | |
qInstallMessageHandler(messageOutput); | |
QApplication app(argc, argv); | |
qDebug() << "Teste"; | |
qWarning() << "Teste"; | |
qCritical() << "Teste"; | |
qFatal("Teste"); | |
return app.exec(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Qt 5.5.1 on Windows 10) - This code example never finishes, and does not write to the console