The QMessageLogger class generates log messages. More...
| Header: | #include <QMessageLogger> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core)target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| QMessageLogger() | |
| QMessageLogger(const char *file, int line, const char *function) | |
| QMessageLogger(const char *file, int line, const char *function, const char *category) | |
| QDebug | critical() const |
| QDebug | critical(QMessageLogger::CategoryFunction catFunc) const |
| QDebug | critical(const QLoggingCategory &cat) const |
| void | critical(const char *msg, ...) const |
| void | critical(QMessageLogger::CategoryFunction catFunc, const char *msg, ...) const |
| void | critical(const QLoggingCategory &cat, const char *msg, ...) const |
| QDebug | debug() const |
| QDebug | debug(QMessageLogger::CategoryFunction catFunc) const |
| QDebug | debug(const QLoggingCategory &cat) const |
| void | debug(const char *msg, ...) const |
| void | debug(QMessageLogger::CategoryFunction catFunc, const char *msg, ...) const |
| void | debug(const QLoggingCategory &cat, const char *msg, ...) const |
(since 6.5) QDebug |
fatal() const |
(since 6.5) QDebug |
fatal(QMessageLogger::CategoryFunction catFunc) const |
(since 6.5) QDebug |
fatal(const QLoggingCategory &cat) const |
| void | fatal(const char *msg, ...) const |
(since 6.5) void |
fatal(QMessageLogger::CategoryFunction catFunc, const char *msg, ...) const |
(since 6.5) void |
fatal(const QLoggingCategory &cat, const char *msg, ...) const |
| QDebug | info() const |
| QDebug | info(QMessageLogger::CategoryFunction catFunc) const |
| QDebug | info(const QLoggingCategory &cat) const |
| void | info(const char *msg, ...) const |
| void | info(QMessageLogger::CategoryFunction catFunc, const char *msg, ...) const |
| void | info(const QLoggingCategory &cat, const char *msg, ...) const |
| QDebug | warning() const |
| QDebug | warning(QMessageLogger::CategoryFunction catFunc) const |
| QDebug | warning(const QLoggingCategory &cat) const |
| void | warning(const char *msg, ...) const |
| void | warning(QMessageLogger::CategoryFunction catFunc, const char *msg, ...) const |
| void | warning(const QLoggingCategory &cat, const char *msg, ...) const |
QMessageLogger is used to generate messages for the Qt logging framework. Usually one uses it through qDebug(), qInfo(), qWarning(), qCritical, or qFatal() functions, which are actually macros: For example qDebug() expands to QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO).debug() for debug builds, and QMessageLogger(0, 0, 0).debug() for release builds.
One example of direct use is to forward errors that stem from a scripting language, e.g. QML:
void statusChanged(QQmlComponent::Status status) { if (status == QQmlComponent::Error) { for (const QQmlError &error: std::as_const(component->errors())) { const QByteArray file = error.url().toEncoded(); QMessageLogger(file.constData(), error.line(), 0).debug() << error.description(); } } }
See also QMessageLogContext, qDebug(), qInfo(), qWarning(), qCritical(), and qFatal().
This is a typedef for a pointer to a function with the following signature:
const QLoggingCategory &category();
The Q_DECLARE_LOGGING_CATEGORY macro generates a function declaration with this signature, and Q_LOGGING_CATEGORY generates its definition.
See also QLoggingCategory.
[constexpr] QMessageLogger::QMessageLogger()Constructs a default QMessageLogger. See the other constructors to specify context information.
[constexpr] QMessageLogger::QMessageLogger(const char *file,
int line, const char *function)Constructs a QMessageLogger to record log messages for file at line in function. The is equivalent to QMessageLogger(file, line, function, "default")
[constexpr] QMessageLogger::QMessageLogger(const char *file,
int line, const char *function, const char *category)Constructs a QMessageLogger to record category messages for file at line in function.
See also QLoggingCategory.
Logs a critical message using a QDebug stream
See also qCritical() and QDebug.
Logs a critical message into category returned by catFunc using a QDebug stream.
See also qCCritical() and QDebug.
Logs a critical message into category cat using a QDebug stream.
See also qCCritical() and QDebug.
Logs a critical message specified with format msg. Additional parameters, specified by msg, may be used.
See also qCritical().
Logs a critical message specified with format msg for the context returned by catFunc. Additional parameters, specified by msg, may be used.
See also qCCritical().
Logs a critical message specified with format msg for the context cat. Additional parameters, specified by msg, may be used.
See also qCCritical().
Logs a debug message using a QDebug stream
Logs a debug message into category returned by catFunc using a QDebug stream.
See also qCDebug() and QDebug.
Logs a debug message into category cat using a QDebug stream.
See also qCDebug() and QDebug.
Logs a debug message specified with format msg. Additional parameters, specified by msg, may be used.
See also qDebug().
Logs a debug message specified with format msg for the context returned by catFunc. Additional parameters, specified by msg, may be used.
See also qCDebug().
Logs a debug message specified with format msg for the context cat. Additional parameters, specified by msg, may be used.
See also qCDebug().
[since 6.5] QDebug QMessageLogger::fatal() constLogs a fatal message using a QDebug stream.
This function was introduced in Qt 6.5.
[since 6.5] QDebug QMessageLogger::fatal(QMessageLogger::CategoryFunction catFunc) constLogs a fatal message into category returned by catFunc using a QDebug stream.
This function was introduced in Qt 6.5.
See also qCFatal() and QDebug.
[since 6.5] QDebug QMessageLogger::fatal(const
QLoggingCategory &cat) constLogs a fatal message into category cat using a QDebug stream.
This function was introduced in Qt 6.5.
See also qCFatal() and QDebug.
[noexcept] void QMessageLogger::fatal(const char
*msg, ...) constLogs a fatal message specified with format msg. Additional parameters, specified by msg, may be used.
See also qFatal().
[noexcept, since 6.5] void QMessageLogger::fatal(QMessageLogger::CategoryFunction catFunc, const char *msg, ...) constLogs a fatal message specified with format msg for the context returned by catFunc. Additional parameters, specified by msg, may be used.
This function was introduced in Qt 6.5.
See also qCFatal().
[noexcept, since 6.5] void QMessageLogger::fatal(const QLoggingCategory &cat, const char *msg, ...) constLogs a fatal message specified with format msg for the context cat. Additional parameters, specified by msg, may be used.
This function was introduced in Qt 6.5.
See also qCFatal().
Logs an informational message using a QDebug stream.
Logs an informational message into category returned by catFunc using a QDebug stream.
Logs an informational message into the category cat using a QDebug stream.
Logs an informational message specified with format msg. Additional parameters, specified by msg, may be used.
See also qInfo().
Logs an informational message specified with format msg for the context returned by catFunc. Additional parameters, specified by msg, may be used.
See also qCInfo().
Logs an informational message specified with format msg for the context cat. Additional parameters, specified by msg, may be used.
See also qCInfo().
Logs a warning message using a QDebug stream
See also qWarning() and QDebug.
Logs a warning message into category returned by catFunc using a QDebug stream.
See also qCWarning() and QDebug.
Logs a warning message into category cat using a QDebug stream.
See also qCWarning() and QDebug.
Logs a warning message specified with format msg. Additional parameters, specified by msg, may be used.
See also qWarning().
Logs a warning message specified with format msg for the context returned by catFunc. Additional parameters, specified by msg, may be used.
See also qCWarning().
Logs a warning message specified with format msg for the context cat. Additional parameters, specified by msg, may be used.
See also qCWarning().