forked from olive-editor/olive
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdebug.cpp
32 lines (28 loc) · 792 Bytes
/
debug.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
#include "debug.h"
#include <QFile>
#include <QDateTime>
#include <QStandardPaths>
#ifndef QT_DEBUG
QFile debug_file;
QDebug debug_out(&debug_file);
#endif
void setup_debug() {
#ifndef QT_DEBUG
debug_file.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/debug_log");
if (debug_file.open(QFile::WriteOnly)) {
QString debug_intro = "Olive Session " + QString::number(QDateTime::currentMSecsSinceEpoch());
debug_file.write(debug_intro.toLatin1());
} else {
debug_out = QMessageLogger(QT_MESSAGELOG_FILE, QT_MESSAGELOG_LINE, QT_MESSAGELOG_FUNC).debug();
}
#endif
}
void close_debug() {
#ifndef QT_DEBUG
if (debug_file.isOpen()) {
debug_file.putChar(10);
debug_file.putChar(10);
debug_file.close();
}
#endif
}