QtWebApp
filelogger.h
Go to the documentation of this file.
1
6#ifndef FILELOGGER_H
7#define FILELOGGER_H
8
9#include <QtGlobal>
10#include <QSettings>
11#include <QFile>
12#include <QMutex>
13#include <QBasicTimer>
14#include "logglobal.h"
15#include "logger.h"
16
17namespace stefanfrings {
18
56class DECLSPEC FileLogger : public Logger {
57 Q_OBJECT
58 Q_DISABLE_COPY(FileLogger)
59public:
60
72 FileLogger(QSettings* settings, const int refreshInterval=10000, QObject* parent = nullptr);
73
77 virtual ~FileLogger();
78
80 virtual void write(const LogMessage* logMessage);
81
82protected:
83
90 void timerEvent(QTimerEvent* event);
91
92private:
93
95 QString fileName;
96
98 long maxSize;
99
101 int maxBackups;
102
104 QSettings* settings;
105
107 QFile* file;
108
110 QBasicTimer refreshTimer;
111
113 QBasicTimer flushTimer;
114
116 void open();
117
119 void close();
120
122 void rotate();
123
128 void refreshSettings();
129
130};
131
132} // end of namespace
133
134#endif // FILELOGGER_H
Logger that uses a text file for output.
Definition: filelogger.h:56
Represents a single log message together with some data that are used to decorate the log message.
Definition: logmessage.h:37
Decorates and writes log messages to the console, stderr.
Definition: logger.h:52