DtkCore
DTK Core module
Dtk::Core::AbstractAppender类 参考abstract

The AbstractAppender class provides an abstract base class for writing a log entries. 更多...

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

Public 成员函数

 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)=0
 Writes the log record to the logger instance 更多...
 

详细描述

The AbstractAppender class provides an abstract base class for writing a log entries.

\inmodule dtkcore

The AbstractAppender class is the base interface class for all log appenders that could be used with Logger.

AbstractAppender provides a common implementation for the thread safe, mutex-protected logging of application messages, such as ConsoleAppender, FileAppender or something else. AbstractAppender is abstract and can not be instantiated, but you can use any of its subclasses or create a custom log appender at your choice.

Appenders are the logical devices that is aimed to be attached to Logger object by calling Logger::registerAppender(). On each log record call from the application Logger object sequentially calls write() function on all the appenders registered in it.

You can subclass AbstractAppender to implement a logging target of any kind you like. It may be the external logging subsystem (for example, syslog in *nix), XML file, SQL database entries, D-Bus messages or anything else you can imagine.

For the simple non-structured plain text logging (for example, to a plain text file or to the console output) you may like to subclass the AbstractStringAppender instead of AbstractAppender, which will give you a more convenient way to control the format of the log output.

参见
AbstractStringAppender
Logger::registerAppender()

成员函数说明

◆ append()

void Dtk::Core::AbstractAppender::append ( const QDateTime &  timeStamp,
Logger::LogLevel  logLevel,
const char *  file,
int  line,
const char *  function,
const QString &  category,
const QString &  message 
)
protectedpure virtual

Writes the log record to the logger instance

This function is called every time when user tries to write a message to this AbstractAppender instance using the write() function. Write function works as proxy and transfers only the messages with log level more or equal to the current logLevel().

Overload this function when you are implementing a custom appender.

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.

注解
This function is not needed to be thread safe because it is never called directly by Logger object. The write() function works as a proxy and protects this function from concurrent access.
参见
Logger::write()

Dtk::Core::ConsoleAppender, Dtk::Core::FileAppender, Dtk::Core::OutputDebugAppender , 以及 Dtk::Core::RollingFileAppender 内被实现.

◆ detailsLevel()

Logger::LogLevel Dtk::Core::AbstractAppender::detailsLevel ( ) const

Returns the current details level of appender.

Log records with a log level lower than a current detailsLevel() will be silently ignored by appender and would not be sent to its append() function.

It provides additional logging flexibility, allowing you to set the different severity levels for different types of logs.

注解
This function is thread safe.
返回
The log level.
参见
setDetailsLevel()
Logger::LogLevel

◆ setDetailsLevel() [1/2]

void Dtk::Core::AbstractAppender::setDetailsLevel ( const QString &  level)

Sets the current details level of appender.

This function is provided for convenience, it behaves like an above function.

参见
detailsLevel()
Logger::LogLevel

◆ setDetailsLevel() [2/2]

void Dtk::Core::AbstractAppender::setDetailsLevel ( Logger::LogLevel  level)

Sets the current details level of appender.

Default details level is Logger::Debug

注解
This function is thread safe.
参见
detailsLevel()
Logger::LogLevel

◆ write()

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

This is the function called by Logger object to write a log message to the appender.

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.

注解
This function is thread safe.
参见
Logger::write()
detailsLevel()

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