-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·55 lines (47 loc) · 1.87 KB
/
Copy pathmain.cpp
File metadata and controls
executable file
·55 lines (47 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <QGuiApplication>
#include <QQmlApplicationEngine>
void debugMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
int main(int argc, char *argv[])
{
#ifdef QT_NO_DEBUG
qInstallMessageHandler(debugMessageHandler);
FILE * pFile = fopen("console.log","w");
fclose(pFile);
#endif
QGuiApplication app(argc, argv);
app.setOrganizationName("Far Eastern Federal University, HPC lab");
app.setOrganizationDomain("tef-dvfu.ru");
app.setApplicationName("simpleTimer");
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}
QString prevMsg;
void debugMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
FILE * pFile = fopen("console.log","a");
if (msg==prevMsg){
fprintf(pFile, "|");
} else {
prevMsg=msg;
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
fprintf(pFile, "\nDebug: (%s:%u, %s) %s ", context.file, context.line, context.function, localMsg.constData());
break;
case QtInfoMsg:
fprintf(pFile, "\nInfo: (%s:%u, %s) %s ", context.file, context.line, context.function, localMsg.constData());
break;
case QtWarningMsg:
fprintf(pFile, "\nWarning: (%s:%u, %s) %s ", context.file, context.line, context.function, localMsg.constData());
break;
case QtCriticalMsg:
fprintf(pFile, "\nCritical: (%s:%u, %s) %s ", context.file, context.line, context.function, localMsg.constData());
break;
case QtFatalMsg:
fprintf(pFile, "\nFatal: (%s:%u, %s) %s ", context.file, context.line, context.function, localMsg.constData());
abort();
}
}
fclose(pFile);
}