QtWebApp
|
Writes log messages into two log files simultaneously. More...
#include <dualfilelogger.h>
Public Member Functions | |
DualFileLogger (QSettings *firstSettings, QSettings *secondSettings, const int refreshInterval=10000, QObject *parent=nullptr) | |
Constructor. More... | |
virtual void | log (const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0) |
Decorate and log the message, if type>=minLevel. More... | |
virtual void | clear (const bool buffer=true, const bool variables=true) |
Clear the thread-local data of the current thread. More... | |
![]() | |
Logger (QObject *parent) | |
Constructor. More... | |
Logger (const QString msgFormat="{timestamp} {type} {msg}", const QString timestampFormat="dd.MM.yyyy hh:mm:ss.zzz", const QtMsgType minLevel=QtDebugMsg, const int bufferSize=0, QObject *parent=nullptr) | |
Constructor. More... | |
virtual | ~Logger () |
Destructor. | |
void | installMsgHandler () |
Installs this logger as the default message handler, so it can be used through the global static logging functions (e.g. More... | |
Additional Inherited Members | |
![]() | |
static void | set (const QString &name, const QString &value) |
Sets a thread-local variable that may be used to decorate log messages. More... | |
![]() | |
virtual void | write (const LogMessage *logMessage) |
Decorate and write a log message to stderr. More... | |
![]() | |
QString | msgFormat |
Format string for message decoration. | |
QString | timestampFormat |
Format string of timestamps. | |
QtMsgType | minLevel |
Minimum level of message types that are written out directly or trigger writing the buffered content. | |
int | bufferSize |
Size of backtrace buffer, number of messages per thread. More... | |
![]() | |
static QMutex | mutex |
Used to synchronize access of concurrent threads. | |
Writes log messages into two log files simultaneously.
I recommend to configure:
Definition at line 28 of file dualfilelogger.h.
DualFileLogger::DualFileLogger | ( | QSettings * | firstSettings, |
QSettings * | secondSettings, | ||
const int | refreshInterval = 10000 , |
||
QObject * | parent = nullptr |
||
) |
Constructor.
firstSettings | Configuration settings for the primary FileLogger instance, usually stored in an INI file. Must not be 0. Settings are read from the current group, so the caller must have called settings->beginGroup(). Because the group must not change during runtime, it is recommended to provide a separate QSettings instance that is not used by other parts of the program. The FileLogger does not take over ownership of the QSettings instance, so the caller should destroy it during shutdown. |
secondSettings | Same as firstSettings, but for the secondary FileLogger instance. |
refreshInterval | Interval of checking for changed config settings in msec, or 0=disabled |
parent | Parent object. |
Definition at line 10 of file dualfilelogger.cpp.
|
virtual |
Clear the thread-local data of the current thread.
This method is thread safe.
buffer | Whether to clear the backtrace buffer |
variables | Whether to clear the log variables |
Reimplemented from stefanfrings::Logger.
Definition at line 23 of file dualfilelogger.cpp.
|
virtual |
Decorate and log the message, if type>=minLevel.
This method is thread safe.
type | Message type (level) |
message | Message text |
file | Name of the source file where the message was generated (usually filled with the macro FILE) |
function | Name of the function where the message was generated (usually filled with the macro LINE) |
line | Line Number of the source file, where the message was generated (usually filles with the macro func or FUNCTION) |
Reimplemented from stefanfrings::Logger.
Definition at line 17 of file dualfilelogger.cpp.