-
Notifications
You must be signed in to change notification settings - Fork 37
/
logger.hpp
59 lines (44 loc) · 1.22 KB
/
logger.hpp
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
53
54
55
56
57
58
59
#ifndef LOGGER_HPP
#define LOGGER_HPP
#include <QObject>
#include "logfiltersetup.hpp"
class QSettings;
namespace Logging {
typedef enum {
error,
warning,
info,
success,
NUM_SEVERITY_LEVELS
} LogLevelE;
struct ILogTransport
{
virtual void appendTime(const QString& dateTime) = 0;
virtual void appendLevelAndFacility(LogLevelE level, const QString& levelFacility) = 0;
virtual void appendMessage(const QString& msg) = 0;
};
class Logger : public QObject
{
Q_OBJECT
typedef QList<ILogTransport*> LogTransportList;
public:
explicit Logger(QObject *parent = 0);
void log(const QString &facility, const QString &message, LogLevelE level);
bool addTransport(ILogTransport* pTransport);
bool removeTransport(ILogTransport* pTransport);
// filters
void configureFilters(QWidget *parent);
void saveFilters(QSettings& sets);
void loadFilters(QSettings& sets);
static Logger& getLoggerInstance();
signals:
public slots:
private:
LogTransportList m_transports;
LogFilterMap m_filters;
QVector<bool> m_levels;
};
Logger& loggerInstance();
void Log(const QString& facility, Logging::LogLevelE level, const QString& message);
} // namespace Logger
#endif // LOGGER_HPP