Public Member Functions | Protected Member Functions

FileLogger Class Reference

Logger that uses a text file for output. More...

#include <filelogger.h>

Inheritance diagram for FileLogger:
Logger

List of all members.

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.

Detailed Description

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
  

See also:
set() describes how to set logger variables
LogMessage for a description of the message decoration.
Logger for a descrition of the backtrace buffer

Definition at line 54 of file filelogger.h.


Constructor & Destructor Documentation

FileLogger::FileLogger ( QSettings *  settings,
const int  refreshInterval = 10000,
QObject *  parent = 0 
)

Constructor.

Parameters:
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]

Destructor.

Closes the file.

Definition at line 67 of file filelogger.cpp.


Member Function Documentation

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.

Parameters:
event used to distinguish between the two timers.

Definition at line 154 of file filelogger.cpp.


The documentation for this class was generated from the following files: