QMessageLogContext Class
The QMessageLogContext class carries information about the origin of a log message. More…
| Header | #include <QMessageLogContext> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Functions
| QMessageLogContext() | |
| QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName) |
Public Variables
Detailed Description
An instance of this class is passed to a message handler installed with qInstallMessageHandler(). The qDebug(), qInfo(), qWarning(), qCritical() and qFatal() macros fill in the file, line and function of the statement, and the qCDebug() family adds the name of the category.
See also QMessageLogger, QDebug and QLoggingCategory.
Differences from Qt
The class can be copied, and category is "default" rather than nullptr when a message has no category. Define QT_NO_MESSAGELOGCONTEXT to leave the file, line and function out.
Member Function Documentation
QMessageLogContext::QMessageLogContext()
Constructs an empty context: no file, line or function, in the category "default".
QMessageLogContext::QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName)
Constructs a context for a message from the given fileName, lineNumber and functionName, in the category categoryName.
Member Variable Documentation
const char * QMessageLogContext::category
The logging category of the message. It is "default" for messages written without a category.
const char * QMessageLogContext::file
The name of the source file the message came from, or nullptr.
const char * QMessageLogContext::function
The name of the function the message came from, or nullptr. It is the compiler's pretty function name, so it includes the return type and the parameters; the %{function} message pattern placeholder leaves only the qualified name.
int QMessageLogContext::line
The line number the message came from, or 0.
int QMessageLogContext::version
The version of the context. It is 2, as in Qt 6.