-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.h
52 lines (40 loc) · 1.24 KB
/
Logger.h
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
#ifndef LOGGER_H
#define LOGGER_H
#include <QObject>
#include <QFile>
class Logger : public QObject
{
Q_OBJECT
public:
explicit Logger(QObject *parent = nullptr);
~Logger();
void setLogFile(QString path);
QString getLogFilePath();
bool isLogging();
void logInHex(bool enabled);
bool isHexLoggingEnabled();
void promptWhenOverwriting(bool enabled);
signals:
void loggingStarted();
void loggingStopped();
public slots:
void startLogging();
void stopLogging();
void log(QString text);
private:
bool logging = false;
bool logInHexEnabled = false;
bool promptWhenOverwritingEnabled = false;
QString logFilePath = "C:\\BluetoothLogs\\log.txt"; //Default log file path
QFile *logFile = nullptr;
QString logText; //Log file buffer
bool promptOverwrite();
void writeToFile(QString text);
QStringList convertTextToHex(QString text);
void addHexToBuffer(QStringList hex);
//Preserved states.
//This lets the user change states without interrupting the current logging process
bool preserved_logInHexEnabled = false;
void preserveStates();
};
#endif // LOGGER_H