Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QMessageLogger Class Reference

\inmodule QtCore More...

#include <qlogging.h>

+ Collaboration diagram for QMessageLogger:

Public Member Functions

constexpr QMessageLogger ()
 Constructs a default QMessageLogger.
 
constexpr QMessageLogger (const char *file, int line, const char *function)
 Constructs a QMessageLogger to record log messages for file at line in function.
 
constexpr 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.
 
void debug (const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
 Logs a debug message specified with format msg.
 
void void noDebug (const char *,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
 
void void Q_DECL_COLD_FUNCTION void warning (const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
 Logs a warning message specified with format msg.
 
void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void critical (const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(2
 Logs a critical message specified with format msg.
 
void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION void fatal (const char *msg,...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(2
 Logs a fatal message specified with format msg.
 
void debug (const QLoggingCategory &cat, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
 Logs a debug message specified with format msg for the context cat.
 
void void debug (CategoryFunction catFunc, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
 
void void void info (const QLoggingCategory &cat, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
 Logs an informational message specified with format msg for the context cat.
 
void void void void info (CategoryFunction catFunc, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
 
void void void void Q_DECL_COLD_FUNCTION void warning (const QLoggingCategory &cat, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
 Logs a warning message specified with format msg for the context cat.
 
void void void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void warning (CategoryFunction catFunc, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
 
void void void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void critical (const QLoggingCategory &cat, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
 Logs a critical message specified with format msg for the context cat.
 
void void void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void critical (CategoryFunction catFunc, const char *msg,...) const Q_ATTRIBUTE_FORMAT_PRINTF(3
 
void void void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION void fatal (const QLoggingCategory &cat, const char *msg,...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(3
 Logs a fatal message specified with format msg for the context cat.
 
void void void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION void QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION void fatal (CategoryFunction catFunc, const char *msg,...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(3
 
void void void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION void QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION void QDebug debug () const
 Logs a debug message using a QDebug stream.
 
QDebug debug (const QLoggingCategory &cat) const
 Logs a debug message into category cat using a QDebug stream.
 
QDebug debug (CategoryFunction catFunc) const
 
QDebug info () const
 Logs an informational message using a QDebug stream.
 
QDebug info (const QLoggingCategory &cat) const
 Logs an informational message into the category cat using a QDebug stream.
 
QDebug info (CategoryFunction catFunc) const
 
Q_DECL_COLD_FUNCTION QDebug warning () const
 Logs a warning message using a QDebug stream.
 
Q_DECL_COLD_FUNCTION QDebug warning (const QLoggingCategory &cat) const
 Logs a warning message into category cat using a QDebug stream.
 
Q_DECL_COLD_FUNCTION QDebug warning (CategoryFunction catFunc) const
 
Q_DECL_COLD_FUNCTION QDebug critical () const
 Logs a critical message using a QDebug stream.
 
Q_DECL_COLD_FUNCTION QDebug critical (const QLoggingCategory &cat) const
 Logs a critical message into category cat using a QDebug stream.
 
Q_DECL_COLD_FUNCTION QDebug critical (CategoryFunction catFunc) const
 
Q_DECL_COLD_FUNCTION QDebug fatal () const
 Logs a fatal message using a QDebug stream.
 
Q_DECL_COLD_FUNCTION QDebug fatal (const QLoggingCategory &cat) const
 Logs a fatal message into category cat using a QDebug stream.
 
Q_DECL_COLD_FUNCTION QDebug fatal (CategoryFunction catFunc) const
 
QNoDebug noDebug () const noexcept
 

Public Attributes

void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION void typedef const QLoggingCategory &(* CategoryFunction )()
 This is a typedef for a pointer to a function with the following signature:
 

Detailed Description

\inmodule QtCore

The QMessageLogger class generates log messages.

Since
5.0

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:

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(), qFatal()

Definition at line 71 of file qlogging.h.

Constructor & Destructor Documentation

◆ QMessageLogger() [1/3]

QMessageLogger::QMessageLogger ( )
inlineconstexpr

Constructs a default QMessageLogger.

See the other constructors to specify context information.

Definition at line 75 of file qlogging.h.

◆ QMessageLogger() [2/3]

QMessageLogger::QMessageLogger ( const char * file,
int line,
const char * function )
inlineconstexpr

Constructs a QMessageLogger to record log messages for file at line in function.

The is equivalent to QMessageLogger(file, line, function, "default")

Definition at line 76 of file qlogging.h.

◆ QMessageLogger() [3/3]

QMessageLogger::QMessageLogger ( const char * file,
int line,
const char * function,
const char * category )
inlineconstexpr

Constructs a QMessageLogger to record category messages for file at line in function.

Definition at line 78 of file qlogging.h.

Member Function Documentation

◆ critical() [1/6]

QDebug QMessageLogger::critical ( ) const

Logs a critical message using a QDebug stream.

See also
qCritical(), QDebug

Definition at line 784 of file qlogging.cpp.

References QtCriticalMsg.

◆ critical() [2/6]

Q_DECL_COLD_FUNCTION QDebug QMessageLogger::critical ( CategoryFunction catFunc) const

◆ critical() [3/6]

◆ critical() [4/6]

void QMessageLogger::critical ( const char * msg,
... ) const

Logs a critical message specified with format msg.

Additional parameters, specified by msg, may be used.

See also
qCritical()

Definition at line 727 of file qlogging.cpp.

References qt_message(), and QtCriticalMsg.

Referenced by dumpwarning(), QV4::ConsoleObject::method_assert(), and QQmlPrivate::AOTCompiledContext::writeToConsole().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ critical() [5/6]

QDebug QMessageLogger::critical ( const QLoggingCategory & cat) const

Logs a critical message into category cat using a QDebug stream.

Since
5.3
See also
qCCritical(), QDebug

Definition at line 798 of file qlogging.cpp.

References QMessageLogContext::category, and QtCriticalMsg.

◆ critical() [6/6]

void QMessageLogger::critical ( const QLoggingCategory & cat,
const char * msg,
... ) const

Logs a critical message specified with format msg for the context cat.

Additional parameters, specified by msg, may be used.

Since
5.3
See also
qCCritical()

Definition at line 743 of file qlogging.cpp.

References qt_message(), and QtCriticalMsg.

+ Here is the call graph for this function:

◆ debug() [1/6]

QDebug QMessageLogger::debug ( ) const

Logs a debug message using a QDebug stream.

See also
qDebug(), QDebug

Definition at line 477 of file qlogging.cpp.

References QtDebugMsg.

◆ debug() [2/6]

QDebug QMessageLogger::debug ( CategoryFunction catFunc) const

◆ debug() [3/6]

void void QMessageLogger::debug ( CategoryFunction catFunc,
const char * msg,
... ) const

◆ debug() [4/6]

void QMessageLogger::debug ( const char * msg,
... ) const

Logs a debug message specified with format msg.

Additional parameters, specified by msg, may be used.

See also
qDebug()

Definition at line 389 of file qlogging.cpp.

References qt_message(), and QtDebugMsg.

Referenced by dumpwarning(), QV4::ConsoleObject::method_count(), QV4::ConsoleObject::method_profile(), QV4::ConsoleObject::method_profileEnd(), QV4::ConsoleObject::method_trace(), statusChanged(), writeToConsole(), and QQmlPrivate::AOTCompiledContext::writeToConsole().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ debug() [5/6]

QDebug QMessageLogger::debug ( const QLoggingCategory & cat) const

Logs a debug message into category cat using a QDebug stream.

Since
5.3
See also
qCDebug(), QDebug

Definition at line 491 of file qlogging.cpp.

References QMessageLogContext::category, and QtDebugMsg.

◆ debug() [6/6]

void QMessageLogger::debug ( const QLoggingCategory & cat,
const char * msg,
... ) const

Logs a debug message specified with format msg for the context cat.

Additional parameters, specified by msg, may be used.

Since
5.3
See also
qCDebug()

Definition at line 435 of file qlogging.cpp.

References qt_message(), and QtDebugMsg.

+ Here is the call graph for this function:

◆ fatal() [1/6]

QDebug QMessageLogger::fatal ( ) const

Logs a fatal message using a QDebug stream.

Since
6.5
See also
qFatal(), QDebug

Definition at line 896 of file qlogging.cpp.

References QtFatalMsg.

◆ fatal() [2/6]

Q_DECL_COLD_FUNCTION QDebug QMessageLogger::fatal ( CategoryFunction catFunc) const

◆ fatal() [3/6]

◆ fatal() [4/6]

void QMessageLogger::fatal ( const char * msg,
... ) const
noexcept

Logs a fatal message specified with format msg.

Additional parameters, specified by msg, may be used.

See also
qFatal()

Definition at line 875 of file qlogging.cpp.

References qt_message(), QT_TERMINATE_ON_EXCEPTION, and QtFatalMsg.

Referenced by qt_assert_x().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fatal() [5/6]

QDebug QMessageLogger::fatal ( const QLoggingCategory & cat) const

Logs a fatal message into category cat using a QDebug stream.

Since
6.5
See also
qCFatal(), QDebug

Definition at line 910 of file qlogging.cpp.

References QMessageLogContext::category, and QtFatalMsg.

◆ fatal() [6/6]

void QMessageLogger::fatal ( const QLoggingCategory & cat,
const char * msg,
... ) const
noexcept

Logs a fatal message specified with format msg for the context cat.

Additional parameters, specified by msg, may be used.

Since
6.5
See also
qCFatal()

Definition at line 831 of file qlogging.cpp.

References qt_message(), QT_TERMINATE_ON_EXCEPTION, and QtFatalMsg.

+ Here is the call graph for this function:

◆ info() [1/5]

QDebug QMessageLogger::info ( ) const

Logs an informational message using a QDebug stream.

Since
5.5
See also
qInfo(), QDebug

Definition at line 579 of file qlogging.cpp.

References QtInfoMsg.

◆ info() [2/5]

QDebug QMessageLogger::info ( CategoryFunction catFunc) const

◆ info() [3/5]

void void void void QMessageLogger::info ( CategoryFunction catFunc,
const char * msg,
... ) const

◆ info() [4/5]

QDebug QMessageLogger::info ( const QLoggingCategory & cat) const

Logs an informational message into the category cat using a QDebug stream.

Since
5.5
See also
qCInfo(), QDebug

Definition at line 593 of file qlogging.cpp.

References QMessageLogContext::category, and QtInfoMsg.

◆ info() [5/5]

void QMessageLogger::info ( const QLoggingCategory & cat,
const char * msg,
... ) const

Logs an informational message specified with format msg for the context cat.

Additional parameters, specified by msg, may be used.

Since
5.5
See also
qCInfo()

Definition at line 536 of file qlogging.cpp.

References qt_message(), and QtInfoMsg.

Referenced by dumpwarning(), and QQmlPrivate::AOTCompiledContext::writeToConsole().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ noDebug() [1/2]

QNoDebug QMessageLogger::noDebug ( ) const
noexcept

Returns a QNoDebug object, which is used to ignore debugging output.

See also
QNoDebug, qDebug()

Definition at line 522 of file qlogging.cpp.

◆ noDebug() [2/2]

void QMessageLogger::noDebug ( const char * ,
... ) const

Ignores logging output

See also
QNoDebug, qDebug()

◆ warning() [1/6]

QDebug QMessageLogger::warning ( ) const

Logs a warning message using a QDebug stream.

See also
qWarning(), QDebug

Definition at line 682 of file qlogging.cpp.

References QtWarningMsg.

◆ warning() [2/6]

Q_DECL_COLD_FUNCTION QDebug QMessageLogger::warning ( CategoryFunction catFunc) const

◆ warning() [3/6]

void void void void Q_DECL_COLD_FUNCTION void Q_DECL_COLD_FUNCTION void QMessageLogger::warning ( CategoryFunction catFunc,
const char * msg,
... ) const

◆ warning() [4/6]

void QMessageLogger::warning ( const char * msg,
... ) const

Logs a warning message specified with format msg.

Additional parameters, specified by msg, may be used.

See also
qWarning()

Definition at line 625 of file qlogging.cpp.

References qt_message(), and QtWarningMsg.

Referenced by dumpwarning(), QQmlConnectionSlotDispatcher::impl(), QV4::QObjectSlotDispatcher::impl(), QV4::ConsoleObject::method_profile(), QV4::ConsoleObject::method_profileEnd(), QQuickView::setContent(), QQuickWidget::setContent(), and QQmlPrivate::AOTCompiledContext::writeToConsole().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ warning() [5/6]

QDebug QMessageLogger::warning ( const QLoggingCategory & cat) const

Logs a warning message into category cat using a QDebug stream.

See also
qCWarning(), QDebug

Definition at line 695 of file qlogging.cpp.

References QMessageLogContext::category, and QtWarningMsg.

◆ warning() [6/6]

void QMessageLogger::warning ( const QLoggingCategory & cat,
const char * msg,
... ) const

Logs a warning message specified with format msg for the context cat.

Additional parameters, specified by msg, may be used.

Since
5.3
See also
qCWarning()

Definition at line 641 of file qlogging.cpp.

References qt_message(), and QtWarningMsg.

+ Here is the call graph for this function:

Member Data Documentation

◆ CategoryFunction

QMessageLogger::CategoryFunction

This is a typedef for a pointer to a function with the following signature:

The Q_DECLARE_LOGGING_CATEGORY macro generates a function declaration with this signature, and Q_LOGGING_CATEGORY generates its definition.

Since
5.3

Definition at line 92 of file qlogging.h.


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