CuteLogger
Fast and simple logging solution for Qt based applications
RollingFileAppender.h
1#ifndef ROLLINGFILEAPPENDER_H
2#define ROLLINGFILEAPPENDER_H
3
4#include <QDateTime>
5
6#include <FileAppender.h>
7
22class CUTELOGGERSHARED_EXPORT RollingFileAppender : public FileAppender
23{
24 public:
30 {
32 MinutelyRollover = 0,
42 MonthlyRollover
43 };
44 Q_ENUMS(DatePattern)
45
46 RollingFileAppender(const QString& fileName = QString());
47
48 DatePattern datePattern() const;
49 void setDatePattern(DatePattern datePattern);
50 void setDatePattern(const QString& datePattern);
51
52 QString datePatternString() const;
53
54 void setLogFilesLimit(int limit);
55 int logFilesLimit() const;
56
57 protected:
58 virtual void append(const QDateTime& timeStamp, Logger::LogLevel logLevel, const char* file, int line,
59 const char* function, const QString& category, const QString& message);
60
61 private:
62 void rollOver();
63 void computeRollOverTime();
64 void computeFrequency();
65 void removeOldFiles();
66 void setDatePatternString(const QString& datePatternString);
67
68 QString m_datePatternString;
69 DatePattern m_frequency;
70
71 QDateTime m_rollOverTime;
72 QString m_rollOverSuffix;
73 int m_logFilesLimit;
74 mutable QMutex m_rollingMutex;
75};
76
77#endif // ROLLINGFILEAPPENDER_H
Simple appender that writes the log records to the plain text file.
Definition FileAppender.h:27
virtual void append(const QDateTime &timeStamp, Logger::LogLevel logLevel, const char *file, int line, const char *function, const QString &category, const QString &message)
Write the log record to the file.
Definition FileAppender.cpp:130
LogLevel
Describes the possible severity levels of the log records.
Definition Logger.h:101
The RollingFileAppender class extends FileAppender so that the underlying file is rolled over at a us...
Definition RollingFileAppender.h:23
DatePattern
Definition RollingFileAppender.h:30
@ DailyRollover
Definition RollingFileAppender.h:38
@ WeeklyRollover
Definition RollingFileAppender.h:40
@ HourlyRollover
Definition RollingFileAppender.h:34
@ HalfDailyRollover
Definition RollingFileAppender.h:36