|
QLogger
|
Used to store all log entry informations. More...
Public Member Functions | |
| LogEntry (QtMsgType idType, const QMessageLogContext &context, const QString &msg) | |
| QtMsgType | getType () const |
| Get message log type. | |
| QString | getTypeString () const |
| Get string type. | |
| bool | contextIsAvailable () const |
| Use to know if context informations are available. | |
| const QFileInfo & | getCtxFile () const |
| Get file of source code associated to log entry. | |
| int | getCtxLine () const |
| Get line of source code associated to log entry. | |
| const QString & | getCtxFctSig () const |
| Get function signature. | |
| QString | getCtxFctName () const |
| Get function name. | |
| const QString & | getMsg () const |
| Get log message. | |
Used to store all log entry informations.
This class is used to store all informations related to a log entry, including his context, if available.
By default, context informations are only available in debug builds.
If context informations are needed even on release mode, please use associated macro: QT_MESSAGELOGCONTEXT
See https://doc.qt.io/qt-6/qmessagelogcontext.html for more details
| bool QLogger::LogEntry::contextIsAvailable | ( | ) | const |
Use to know if context informations are available.
true if context informations are available | QString QLogger::LogEntry::getCtxFctName | ( | ) | const |
Get function name.
Since Qt doesn't provide function name context, we searched it using regex. Function signature will be equals to:
MyNamespace::MyClass::myFunction(int, double)
Details of our regex:
(\w+::)*: MyNamespace::, MyClass::(\w+): myFunctions*(.*): (int, double)So, function name will be in the 2nd group. Then, since index 0 of QRegularExpressionMatch is the enire substring captured by the pattern, index to use will be 2 (0 + group 2).
For more details, see: https://doc.qt.io/qt-6/qregularexpressionmatch.html#captured
contextIsAvailable() before using this method| const QString & QLogger::LogEntry::getCtxFctSig | ( | ) | const |
Get function signature.
Function signature will contains type of returned value and all expected arguments types.
contextIsAvailable() before using this method| const QFileInfo & QLogger::LogEntry::getCtxFile | ( | ) | const |
Get file of source code associated to log entry.
contextIsAvailable() before using this method| int QLogger::LogEntry::getCtxLine | ( | ) | const |
Get line of source code associated to log entry.
contextIsAvailable() before using this method| const QString & QLogger::LogEntry::getMsg | ( | ) | const |
Get log message.
| QtMsgType QLogger::LogEntry::getType | ( | ) | const |
Get message log type.
| QString QLogger::LogEntry::getTypeString | ( | ) | const |
Get string type.