mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
dekstop-main.cpp: install a message handler
This way the Windows binaries can properly write to log files. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
6161ca2083
commit
f2911f64ba
1 changed files with 26 additions and 0 deletions
|
@ -29,12 +29,14 @@
|
||||||
|
|
||||||
static bool filesOnCommandLine = false;
|
static bool filesOnCommandLine = false;
|
||||||
static void validateGL();
|
static void validateGL();
|
||||||
|
static void messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg);
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
bool no_filenames = true;
|
bool no_filenames = true;
|
||||||
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
QLoggingCategory::setFilterRules(QStringLiteral("qt.bluetooth* = true"));
|
||||||
|
qInstallMessageHandler(messageHandler);
|
||||||
QApplication *application = new QApplication(argc, argv);
|
QApplication *application = new QApplication(argc, argv);
|
||||||
(void)application;
|
(void)application;
|
||||||
QStringList files;
|
QStringList files;
|
||||||
|
@ -215,3 +217,27 @@ exit:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// install this message handler primarily so that the Windows build can log to files
|
||||||
|
void messageHandler(QtMsgType type, const QMessageLogContext &ctx, const QString &msg)
|
||||||
|
{
|
||||||
|
Q_UNUSED(ctx);
|
||||||
|
QByteArray localMsg = msg.toLocal8Bit();
|
||||||
|
switch (type) {
|
||||||
|
case QtDebugMsg:
|
||||||
|
fprintf(stdout, "%s\n", localMsg.constData());
|
||||||
|
break;
|
||||||
|
case QtInfoMsg:
|
||||||
|
fprintf(stdout, "%s\n", localMsg.constData());
|
||||||
|
break;
|
||||||
|
case QtWarningMsg:
|
||||||
|
fprintf(stderr, "%s\n", localMsg.constData());
|
||||||
|
break;
|
||||||
|
case QtCriticalMsg:
|
||||||
|
fprintf(stderr, "%s\n", localMsg.constData());
|
||||||
|
break;
|
||||||
|
case QtFatalMsg:
|
||||||
|
fprintf(stderr, "%s\n", localMsg.constData());
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue