DtkCore
DTK Core module
Dtk::Core::RollingFileAppender类 参考

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

类 Dtk::Core::RollingFileAppender 继承关系图:
Dtk::Core::FileAppender Dtk::Core::AbstractStringAppender Dtk::Core::AbstractAppender

Public 类型

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

Public 成员函数

 RollingFileAppender (const QString &fileName=QString())
 
DatePattern datePattern () const
 
void setDatePattern (DatePattern datePattern)
 
void setDatePattern (const QString &datePattern)
 
QString datePatternString () const
 
void setLogFilesLimit (int limit)
 
int logFilesLimit () const
 
void setLogSizeLimit (int qint64)
 
qint64 logSizeLimit () const
 
- Public 成员函数 继承自 Dtk::Core::FileAppender
 FileAppender (const QString &fileName=QString())
 Constructs the new file appender assigned to file with the given fileName.
 
QString fileName () const
 Returns the name set by setFileName() or to the FileAppender constructor. 更多...
 
void setFileName (const QString &)
 Sets the s name of the file. The name can have no path, a relative path, or an absolute path. 更多...
 
qint64 size () const
 
- Public 成员函数 继承自 Dtk::Core::AbstractStringAppender
 AbstractStringAppender ()
 Constructs a new string appender object.
 
virtual QString format () const
 Returns the current log format string. 更多...
 
void setFormat (const QString &)
 Sets the logging format for writing strings to the log target with this appender. 更多...
 
- Public 成员函数 继承自 Dtk::Core::AbstractAppender
 AbstractAppender ()
 Constructs a AbstractAppender object.
 
virtual ~AbstractAppender ()
 Destructs the AbstractAppender object.
 
Logger::LogLevel detailsLevel () const
 Returns the current details level of appender. 更多...
 
void setDetailsLevel (Logger::LogLevel level)
 Sets the current details level of appender. 更多...
 
void setDetailsLevel (const QString &level)
 Sets the current details level of appender. 更多...
 
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. 更多...
 

Protected 成员函数

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. \reimp 更多...
 
- Protected 成员函数 继承自 Dtk::Core::FileAppender
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. \reimp 更多...
 
bool openFile ()
 
void closeFile ()
 
- Protected 成员函数 继承自 Dtk::Core::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(). 更多...
 
virtual void append (const QDateTime &timeStamp, Logger::LogLevel logLevel, const char *file, int line, const char *function, const QString &category, const QString &message)=0
 Writes the log record to the logger instance 更多...
 

额外继承的成员函数

- 静态 Public 成员函数 继承自 Dtk::Core::AbstractStringAppender
static QString stripFunctionName (const char *)
 Strips the long function signature (as added by Q_FUNC_INFO macro). 更多...
 

详细描述

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

\inmodule dtkcore

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).

成员枚举类型说明

◆ DatePattern

The enum DatePattern defines constants for date patterns.

参见
setDatePattern(DatePattern)
枚举值
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".

成员函数说明

◆ append()

void Dtk::Core::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. \reimp

The timeStamp parameter indicates the time stamp. The logLevel parameter describes the LogLevel. The file parameter is the current file name. The line parameter indicates the number of lines to output. The function parameter indicates the function name to output. The category parameter indicates the log category. The message parameter indicates the output message.

参见
fileName()
AbstractStringAppender::format()

重载 Dtk::Core::FileAppender .


该类的文档由以下文件生成: