itom
Loading...
Searching...
No Matches
itomLog.h
1
2#ifndef ITOM_LOG_H
3#define ITOM_LOG_H
4
5
6#include "retVal.h"
7#include "sharedStructuresQt.h"
8
9#include <qfile.h>
10#include <qfileinfo.h>
11#include <qmutex.h>
12#include <qobject.h>
13#include <qtextstream.h>
14#include <qvector.h>
15
16
17namespace ito {
18
19
29class ITOMCOMMONQT_EXPORT Logger : public QObject
30{
31 Q_OBJECT
32
33public:
43 Logger(
44 QString logFileName, QString logFileDir = "", int fileSizeBytes = 0, int backupCount = 0);
45 ~Logger();
46
47public slots:
55 void writePythonLog(QString msg);
56
60 RetVal copyLog(QString directory, ItomSharedSemaphore* waitCond = nullptr);
61
62private:
63 static bool s_handlerRegistered;
64 static QVector<Logger*> s_instances;
65 QFile m_logFile;
66 QTextStream* m_messageStream;
67 QMutex m_msgOutputProtection;
68
69 static void s_messageHandler(
70 QtMsgType type, const QMessageLogContext& context, const QString& msg);
71
72 void initFiles(int fileSize, int backupCount);
73 QFileInfoList listBackups();
74 void deleteOldBackups(int backupCount);
75 void storeBackupFile();
76 void handleMessage(QtMsgType type, const QMessageLogContext& context, const QString& msg);
77};
78
79
80} // namespace ito
81
82
83#endif // ITOM_LOG_H
semaphore which can be used for asynchronous thread communication. By using this class it is possible...
Definition sharedStructuresQt.h:58
Writes a log file.
Definition itomLog.h:30
Class for managing status values (like errors or warning)
Definition retVal.h:54
Definition apiFunctionsGraph.cpp:40