CuteLogger
Fast and simple logging solution for Qt based applications
Public Types | Protected Member Functions | List of all members
RollingFileAppender Class Reference

The RollingFileAppender class extends FileAppender so that the underlying file is rolled over at a user chosen frequency. More...

#include <RollingFileAppender.h>

Inheritance diagram for RollingFileAppender:
FileAppender AbstractStringAppender AbstractAppender

Public Types

enum  DatePattern {
  MinutelyRollover = 0, HourlyRollover, HalfDailyRollover, DailyRollover,
  WeeklyRollover, MonthlyRollover
}
 

Protected Member Functions

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. More...
 
- Protected Member Functions inherited from AbstractStringAppender
QString formattedString (const QDateTime &timeStamp, Logger::LogLevel logLevel, const char *file, int line, const char *function, const QString &category, const QString &message) const
 Returns the string to record to the logging target, formatted according to the format(). More...
 

Additional Inherited Members

- Public Member Functions inherited from FileAppender
 FileAppender (const QString &fileName=QString())
 Constructs the new file appender assigned to file with the given name.
 
QString fileName () const
 Returns the name set by setFileName() or to the FileAppender constructor. More...
 
void setFileName (const QString &)
 Sets the name of the file. The name can have no path, a relative path, or an absolute path. More...
 
- Public Member Functions inherited from AbstractStringAppender
 AbstractStringAppender ()
 Constructs a new string appender object.
 
virtual QString format () const
 Returns the current log format string. More...
 
void setFormat (const QString &)
 Sets the logging format for writing strings to the log target with this appender. More...
 
- Public Member Functions inherited from AbstractAppender
 AbstractAppender ()
 Constructs a AbstractAppender object.
 
virtual ~AbstractAppender ()
 Destructs the AbstractAppender object.
 
Logger::LogLevel detailsLevel () const
 Returns the current details level of appender. More...
 
void setDetailsLevel (Logger::LogLevel level)
 Sets the current details level of appender. More...
 
void setDetailsLevel (const QString &level)
 Sets the current details level of appender. More...
 
void write (const QDateTime &timeStamp, Logger::LogLevel logLevel, const char *file, int line, const char *function, const QString &category, const QString &message)
 Tries to write the log record to this logger. More...
 
- Static Public Member Functions inherited from AbstractStringAppender
static QString stripFunctionName (const char *)
 Strips the long function signature (as added by Q_FUNC_INFO macro) More...
 

Detailed Description

The RollingFileAppender class extends FileAppender so that the underlying file is rolled over at a user chosen frequency.

The class is based on Log4Qt.DailyRollingFileAppender class (http://log4qt.sourceforge.net/) and has the same date pattern format.

For example, if the fileName is set to /foo/bar and the DatePattern set to the daily rollover ('.'yyyy-MM-dd'.log'), on 2014-02-16 at midnight, the logging file /foo/bar.log will be copied to /foo/bar.2014-02-16.log and logging for 2014-02-17 will continue in /foo/bar until it rolls over the next day.

The logFilesLimit parameter is used to automatically delete the oldest log files in the directory during rollover (so no more than logFilesLimit recent log files exist in the directory at any moment).

See also
setDatePattern(DatePattern), setLogFilesLimit(int)

Member Enumeration Documentation

◆ DatePattern

The enum DatePattern defines constants for date patterns.

See also
setDatePattern(DatePattern)
Enumerator
MinutelyRollover 

The minutely date pattern string is "'.'yyyy-MM-dd-hh-mm".

HourlyRollover 

The hourly date pattern string is "'.'yyyy-MM-dd-hh".

HalfDailyRollover 

The half-daily date pattern string is "'.'yyyy-MM-dd-a".

DailyRollover 

The daily date pattern string is "'.'yyyy-MM-dd".

WeeklyRollover 

The weekly date pattern string is "'.'yyyy-ww".

MonthlyRollover 

The monthly date pattern string is "'.'yyyy-MM".

Member Function Documentation

◆ append()

void RollingFileAppender::append ( const QDateTime &  timeStamp,
Logger::LogLevel  logLevel,
const char *  file,
int  line,
const char *  function,
const QString &  category,
const QString &  message 
)
protectedvirtual

Write the log record to the file.

See also
fileName()
AbstractStringAppender::format()

Reimplemented from FileAppender.


The documentation for this class was generated from the following files: