![]() |
SDRAngel
4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
|
#include <filelogger.h>
Inheritance diagram for qtwebapp::FileLogger:
Collaboration diagram for qtwebapp::FileLogger:Public Member Functions | |
| FileLogger (QSettings *settings, const int refreshInterval=10000, QObject *parent=0) | |
| FileLogger (const FileLoggerSettings &settings, const int refreshInterval=10000, QObject *parent=0) | |
| virtual | ~FileLogger () |
| FileLoggerSettings | getFileLoggerSettings () const |
| void | setFileLoggerSettings (const FileLoggerSettings &settings) |
| virtual void | write (const LogMessage *logMessage) |
Public Member Functions inherited from qtwebapp::Logger | |
| Logger (QObject *parent) | |
| Logger (const QString msgFormat="{timestamp} {type} {msg}", const QString timestampFormat="yyyy-MM-dd HH:mm:ss.zzz", const QtMsgType minLevel=QtDebugMsg, const int bufferSize=0, QObject *parent=0) | |
| virtual | ~Logger () |
| virtual void | log (const QtMsgType type, const QString &message, const QString &file="", const QString &function="", const int line=0) |
| void | installMsgHandler () |
| void | setMinMessageLevel (const QtMsgType &minMsgLevel) |
| QtMsgType | getMinMessageLevel () const |
| virtual void | clear (const bool buffer=true, const bool variables=true) |
Protected Member Functions | |
| void | timerEvent (QTimerEvent *event) |
Private Member Functions | |
| void | open () |
| void | close () |
| void | rotate () |
| void | refreshSettings () |
| void | refreshQtSettings () |
| void | refreshFileLogSettings () |
Private Attributes | |
| QString | fileName |
| long | maxSize |
| int | maxBackups |
| QSettings * | settings |
| FileLoggerSettings | fileLoggerSettings |
| QFile * | file |
| QBasicTimer | refreshTimer |
| QBasicTimer | flushTimer |
| bool | useQtSettings |
Additional Inherited Members | |
Static Public Member Functions inherited from qtwebapp::Logger | |
| static void | set (const QString &name, const QString &value) |
Protected Attributes inherited from qtwebapp::Logger | |
| QString | msgFormat |
| QString | timestampFormat |
| QtMsgType | minLevel |
| int | bufferSize |
Static Protected Attributes inherited from qtwebapp::Logger | |
| static QMutex | mutex |
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.
Example for the configuration settings:
fileName=logs/QtWebApp.log
maxSize=1000000
maxBackups=2
minLevel=0
msgformat={timestamp} {typeNr} {type} thread={thread}: {msg}
timestampFormat=yyyy-MM-dd 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 for changed config settings in msec, or 0=disabled |
| parent | Parent object |
Definition at line 97 of file filelogger.cpp.
References file, flushTimer, refreshSettings(), refreshTimer, and settings.
Here is the call graph for this function:| FileLogger::FileLogger | ( | const FileLoggerSettings & | settings, |
| const int | refreshInterval = 10000, |
||
| QObject * | parent = 0 |
||
| ) |
Constructor.
| settings | Configuration settings as a simple structure (see: FileLoggerSettings). |
| refreshInterval | Interval of checking for changed config settings in msec, or 0=disabled |
| parent | Parent object |
Definition at line 115 of file filelogger.cpp.
References file, fileLoggerSettings, flushTimer, refreshSettings(), refreshTimer, and settings.
Here is the call graph for this function:
|
virtual |
Destructor. Closes the file.
Definition at line 132 of file filelogger.cpp.
References close().
Here is the call graph for this function:
|
private |
Close the output file
Definition at line 188 of file filelogger.cpp.
References file.
Referenced by refreshFileLogSettings(), refreshQtSettings(), timerEvent(), write(), and ~FileLogger().
Here is the caller graph for this function:
|
inline |
Get a file logger settings copy
Definition at line 87 of file filelogger.h.
Referenced by qtwebapp::LoggerWithFile::getLogFileName().
Here is the caller graph for this function:
|
private |
Open the output file
Definition at line 166 of file filelogger.cpp.
References file, and fileName.
Referenced by refreshFileLogSettings(), refreshQtSettings(), and timerEvent().
Here is the caller graph for this function:
|
private |
Refreshes the configuration settings with file log settings structure.
Definition at line 68 of file filelogger.cpp.
References qtwebapp::FileLoggerSettings::bufferSize, qtwebapp::Logger::bufferSize, close(), fileLoggerSettings, qtwebapp::FileLoggerSettings::fileName, fileName, qtwebapp::FileLoggerSettings::maxBackups, maxBackups, qtwebapp::FileLoggerSettings::maxSize, maxSize, qtwebapp::FileLoggerSettings::minLevel, qtwebapp::Logger::minLevel, qtwebapp::FileLoggerSettings::msgFormat, qtwebapp::Logger::msgFormat, open(), qtwebapp::FileLoggerSettings::timestampFormat, and qtwebapp::Logger::timestampFormat.
Referenced by refreshSettings().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Refreshes the configuration settings with Qt settings.
Definition at line 32 of file filelogger.cpp.
References qtwebapp::Logger::bufferSize, close(), fileName, maxBackups, maxSize, qtwebapp::Logger::minLevel, qtwebapp::Logger::msgFormat, open(), settings, and qtwebapp::Logger::timestampFormat.
Referenced by refreshSettings().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Refreshes the configuration settings. This method is thread-safe.
Definition at line 19 of file filelogger.cpp.
References qtwebapp::Logger::mutex, refreshFileLogSettings(), refreshQtSettings(), and useQtSettings.
Referenced by FileLogger(), and timerEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Rotate files and delete some backups if there are too many
Definition at line 198 of file filelogger.cpp.
References arg(), fileName, i, and maxBackups.
Referenced by timerEvent().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Set new file logger settings data
| File | logger settings to replace current data |
Definition at line 93 of file filelogger.h.
Referenced by qtwebapp::LoggerWithFile::createOrSetFileLogger().
Here is the caller graph for this function:
|
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 232 of file filelogger.cpp.
References close(), file, flushTimer, maxSize, qtwebapp::Logger::mutex, open(), refreshSettings(), refreshTimer, and rotate().
Here is the call graph for this function:
|
virtual |
Write a message to the log file
Reimplemented from qtwebapp::Logger.
Definition at line 137 of file filelogger.cpp.
References close(), file, fileName, qtwebapp::LogMessage::getType(), qtwebapp::Logger::msgFormat, qtwebapp::Logger::timestampFormat, qtwebapp::LogMessage::toString(), useQtSettings, and qtwebapp::Logger::write().
Here is the call graph for this function:
|
private |
Output file, or 0=disabled
Definition at line 126 of file filelogger.h.
Referenced by close(), FileLogger(), open(), timerEvent(), and write().
|
private |
Pointer to the configuration settings
Definition at line 123 of file filelogger.h.
Referenced by FileLogger(), and refreshFileLogSettings().
|
private |
Configured name of the log file
Definition at line 111 of file filelogger.h.
Referenced by open(), refreshFileLogSettings(), refreshQtSettings(), rotate(), and write().
|
private |
Timer for flushing the file I/O buffer
Definition at line 132 of file filelogger.h.
Referenced by FileLogger(), and timerEvent().
|
private |
Configured maximum number of backup files, or 0=unlimited
Definition at line 117 of file filelogger.h.
Referenced by refreshFileLogSettings(), refreshQtSettings(), and rotate().
|
private |
Configured maximum size of the file in bytes, or 0=unlimited
Definition at line 114 of file filelogger.h.
Referenced by refreshFileLogSettings(), refreshQtSettings(), and timerEvent().
|
private |
Timer for refreshing configuration settings
Definition at line 129 of file filelogger.h.
Referenced by FileLogger(), and timerEvent().
|
private |
Pointer to the configuration settings
Definition at line 120 of file filelogger.h.
Referenced by FileLogger(), and refreshQtSettings().
|
private |
Use of Qt settings or simple structure settings
Definition at line 135 of file filelogger.h.
Referenced by refreshSettings(), and write().
1.8.13