-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (69 loc) · 2.12 KB
/
Copy pathmain.cpp
File metadata and controls
81 lines (69 loc) · 2.12 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "mainwindow.h"
#include <QApplication>
#include <QtCore>
#include "Status/status.h"
#include "Status/finalstatus.h"
#include "Status/analyzerstatus.h"
#include "Status/workerstatus.h"
#include <QMutex>
#ifndef QT_DEBUG
QTextStream *out = 0;
void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
Q_UNUSED(context);
static QMutex mutex;
QMutexLocker locker(&mutex);
QByteArray localMsg = msg.toLocal8Bit();
switch (type) {
case QtDebugMsg:
*out << "[Debug] " << localMsg << "\n";
break;
case QtInfoMsg:
*out << "[Info] " << localMsg << "\n";
break;
case QtWarningMsg:
*out << "[Warning] " << localMsg << "\n";
break;
case QtCriticalMsg:
*out << "[Critical] " << localMsg << "\n";
break;
case QtFatalMsg:
*out << "[Fatal] " << localMsg << "\n";
out->flush();
abort();
break;
}
out->flush();
}
#endif // QT_DEBUG
int main(int argc, char *argv[])
{
QCoreApplication::setApplicationVersion(APP_VERSION);
QCoreApplication::setOrganizationName("WISI Norden AB");
QCoreApplication::setOrganizationDomain("wisi.se");
QCoreApplication::setApplicationName("IPTV Utilities");
qRegisterMetaType<Status>();
qRegisterMetaType<WorkerStatus>();
qRegisterMetaType<FinalStatus>();
qRegisterMetaType<AnalyzerStatus>();
QApplication a(argc, argv);
#ifndef QT_DEBUG
QString path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
if (path.length() > 0) {
QString fileName = path + "/IPTVUtils.log";
QDir dir;
dir.mkpath(path);
QFile *log = new QFile(fileName);
if (log->open(QIODevice::WriteOnly | QIODevice::Text)) {
out = new QTextStream(log);
qInstallMessageHandler(myMessageOutput);
} else {
qDebug() << "Error opening log file '" << fileName << "'. All debug output redirected to console.";
}
}
#endif // QT_DEBUG
MainWindow w;
w.show();
qInfo() << QThread::currentThread();
return a.exec();
}