-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLogger.h
41 lines (39 loc) · 881 Bytes
/
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
#ifndef LOGGER_H
#define LOGGER_H
#include <QObject>
#include <QDebug>
#include <QThread>
#include <QMutex>
#include <QWaitCondition>
#include <QListWidget>
#include <QDateTime>
#include <QQueue>
typedef struct {
QtMsgType type;
QString file;
int line;
QString function;
QString message;
QDateTime time;
bool flushTag;
} Log;
class Logger : public QThread{
Q_OBJECT
public:
static bool verbose;
static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);
static Logger* instance();
Logger();
void enqueue(Log log);
void addToLogWidget(Log log);
void setLogWidget(QListWidget* widget);
protected:
void run();
private:
static Logger* m_instance;
QListWidget* logWidget;
QMutex* qMutex;
QWaitCondition* qNotEmpty;
QQueue<Log>* logQueue;
};
#endif // LOGGER_H