DtkCore
DTK Core module
|
The AbstractStringAppender class provides a convenient base for appenders working with plain text formatted logs. 更多...
Public 成员函数 | |
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. 更多... | |
![]() | |
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. 更多... | |
静态 Public 成员函数 | |
static QString | stripFunctionName (const char *) |
Strips the long function signature (as added by Q_FUNC_INFO macro). 更多... | |
Protected 成员函数 | |
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 更多... | |
The AbstractStringAppender class provides a convenient base for appenders working with plain text formatted logs.
\inmodule dtkcore
AbstractSringAppender is the simple extension of the AbstractAppender class providing the convenient way to create custom log appenders working with a plain text formatted log targets.
It have the formattedString() protected function that formats the logging arguments according to a format set with setFormat().
This class can not be directly instantiated because it contains pure virtual function inherited from AbstractAppender class.
For more detailed description of customizing the log output format see the documentation on the setFormat() function.
|
virtual |
Returns the current log format string.
The default format is set to "%{time}{yyyy-MM-ddTHH:mm:ss.zzz} [%{type:-7}] <%{function}> %{message}\n". You can set a different log record format using the setFormat() function.
|
protected |
Returns the string to record to the logging target, formatted according to the format().
timeStamp The time stamp. The logLevel parameter describes the LogLevel, and the file parameter is the current file name, and 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.
void Dtk::Core::AbstractStringAppender::setFormat | ( | const QString & | format | ) |
Sets the logging format for writing strings to the log target with this appender.
The string format seems to be very common to those developers who have used a standard sprintf function.
Log output format is a simple QString with the special markers (starting with % sign) which will be replaced with it's internal meaning when writing a log record.
Controlling marker begins with the percent sign (%) which is followed by the command inside {} brackets (the command describes, what will be put to log record instead of marker). Optional field width argument may be specified right after the command (through the colon symbol before the closing bracket) Some commands requires an additional formatting argument (in the second {} brackets).
Field width argument works almost identically to the QString::arg() fieldWidth argument (and uses it internally). For example, "%{type:-7}" will be replaced with the left padded debug level of the message ("Debug ") or something. For the more detailed description of it you may consider to look to the Qt Reference Documentation.
Supported marker commands are: \list
|
static |
Strips the long function signature (as added by Q_FUNC_INFO macro).
The string processing drops the returning type, arguments and template parameters of function. It is definitely useful for enchancing the log output readability.
The name parameter is the function name.