iVS3D v2.0.9
Loading...
Searching...
No Matches
logmanager.h
1#ifndef LOGMANAGER_H
2#define LOGMANAGER_H
3
4#include <QList>
5#include <QJsonObject>
6#include <QFile>
7#include <QDir>
8#include <QCoreApplication>
9#include <memory>
10
11#include "stringcontainer.h"
12#include "logfile.h"
13
14#define FILE_NAME_SUFFIX "_ddMMyyyy_hhmmss"
15#define FULL_FILE_PATH m_logDir + (QString)"/" + m_fileName + (QString)".json"
16
29class LogManager : public QObject
30{
31 Q_OBJECT
32
33public:
38 static LogManager& instance();
45 std::shared_ptr<LogFile> createLogFile(QString name, bool isPlugin);
49 void deleteAllLogFiles();
54 QJsonDocument toJSON();
55
59 void resetLog();
65 void toggleLog(bool useLog);
72 void setLogDirectory(QString logDir);
73
74public slots:
75
80 bool slot_updateLog();
81
82private:
83 bool print();
84 LogManager();
85 QList<QPair<QString, std::shared_ptr<LogFile>>> m_allLogFiles;
86 QString m_fileName;
87 QString m_logDir;
88 bool m_logEnabled = true;
89};
90
91#endif // LOGMANAGER_H
The LogManager class is a singleton which manages the logging process. It provides LogFiles that are ...
Definition logmanager.h:30
static LogManager & instance()
Returns the singleton instance of this class.
Definition logmanager.cpp:11
void toggleLog(bool useLog)
toggleLog is used to enable or disable loging (-> saving the log file to disk or not)
Definition logmanager.cpp:59
std::shared_ptr< LogFile > createLogFile(QString name, bool isPlugin)
createLogFile Returns the pointer to an already existing LogFile or creates a new one if neccessary....
Definition logmanager.cpp:17
void deleteAllLogFiles()
deleteAllLogFiles Deletes all LogFiles. Every existing pointer is invalid now.
Definition logmanager.cpp:26
void setLogDirectory(QString logDir)
setLogDirectory changes the directory where the log file is printed to. It wont an artifical folder i...
Definition logmanager.cpp:64
void resetLog()
resetLog resets the current log and creates a new log
Definition logmanager.cpp:53
bool slot_updateLog()
update is called whenever a logfile changes. This will print the current log files.
Definition logmanager.cpp:69
QJsonDocument toJSON()
toQJSON Returns the current state of the log files in form of a QJsonObject
Definition logmanager.cpp:38