Logger that uses a text file for output. More...
#include <filelogger.h>
Public Member Functions | |
FileLogger (QSettings *settings, const int refreshInterval=10000, QObject *parent=0) | |
Constructor. | |
virtual | ~FileLogger () |
Destructor. | |
virtual void | write (const LogMessage *logMessage) |
Write a message to the log file. | |
Protected Member Functions | |
void | timerEvent (QTimerEvent *event) |
Handler for timer events. |
Logger that uses a text file for output.
Settings are read from a config file using a QSettings object. Config settings can be changed at runtime. They are copied to private fields in regular intervals for permance reason.
Example for the required configuration settings:
disabled=false fileName=logs/QtWebApp.log maxSize=1000000 maxBackups=2 minLevel=0 msgformat={timestamp} {typeNr} {type} thread={thread}: {msg} timestampFormat=dd.MM.yyyy hh:mm:ss.zzz bufferSize=0
Definition at line 54 of file filelogger.h.
FileLogger::FileLogger | ( | QSettings * | settings, | |
const int | refreshInterval = 10000 , |
|||
QObject * | parent = 0 | |||
) |
Constructor.
settings | Configuration settings, 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 to the logger that is not used by other parts of the program. | |
refreshInterval | Interval of checking the config settings in msec, or 0=disabled | |
parent | Parent object |
Definition at line 53 of file filelogger.cpp.
FileLogger::~FileLogger | ( | ) | [virtual] |
void FileLogger::timerEvent | ( | QTimerEvent * | event | ) | [protected] |
Handler for timer events.
Refreshes config settings or synchronizes I/O buffer, depending on the event. This method is thread-safe.
event | used to distinguish between the two timers. |
Definition at line 154 of file filelogger.cpp.