-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
51 lines (42 loc) · 1.57 KB
/
main.cpp
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
#include "mainwindow.h"
#include <QApplication>
#include <QTextCodec>
#include <QSettings>
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
QFile file("log.txt");
if (file.open(QIODevice::Append)) {
QTextStream log_stream(&file);
log_stream << localMsg.constData() << "\n";
}
switch (type) {
case QtDebugMsg:
fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtInfoMsg:
fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtWarningMsg:
fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function);
break;
case QtCriticalMsg:
fprintf(stderr, "Critical: %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(myMessageOutput);
QApplication a(argc, argv);
QCoreApplication::setApplicationName("Spin Stats");
QCoreApplication::setOrganizationName("Ressurection Technologies");
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
MainWindow w;
w.show();
return a.exec();
}