Qt 6.x
The Qt SDK
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:

void statusChanged(QDeclarativeComponent::Status status) {
if (status == QDeclarativeComponent::Error) {
foreach (const QDeclarativeError &error, component->errors()) {
const QByteArray file = error.url().toEncoded();
QMessageLogger(file.constData(), error.line(), 0).debug() << error.description();
}
}
}
\inmodule QtCore
Definition qbytearray.h:57
constexpr QMessageLogger()
Constructs a default QMessageLogger.
Definition qlogging.h:71
void statusChanged(QDeclarativeComponent::Status status)
[1]
Definition qlogging.cpp:9
DBusConnection const char DBusError * error
static qreal component(const QPointF &point, unsigned int i)
QFile file
[0]
See also
QMessageLogContext, qDebug(), qInfo(), qWarning(), qCritical(), qFatal()

Definition at line 67 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 71 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 72 of file qlogging.h.

References function.

◆ 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 74 of file qlogging.h.

References function.

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 833 of file qlogging.cpp.

References QtCriticalMsg.

◆ critical() [2/6]

Q_DECL_COLD_FUNCTION QDebug QMessageLogger::critical ( CategoryFunction  catFunc) const

◆ critical() [3/6]

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

◆ 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 764 of file qlogging.cpp.

References isFatal(), qt_message(), qt_message_fatal(), 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 847 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), QLoggingCategory::isCriticalEnabled(), and QtCriticalMsg.

+ Here is the call graph for this function:

◆ 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 782 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), QLoggingCategory::isCriticalEnabled(), isFatal(), qt_message(), qt_message_fatal(), 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 489 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 385 of file qlogging.cpp.

References isFatal(), qt_message(), qt_message_fatal(), and QtDebugMsg.

Referenced by dumpwarning(), QV4::ConsoleObject::method_count(), QV4::ConsoleObject::method_profile(), QV4::ConsoleObject::method_profileEnd(), QV4::ConsoleObject::method_trace(), statusChanged(), 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 503 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), QLoggingCategory::isDebugEnabled(), and QtDebugMsg.

+ Here is the call graph for this function:

◆ 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 437 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), QLoggingCategory::isDebugEnabled(), isFatal(), qt_message(), qt_message_fatal(), 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 950 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 930 of file qlogging.cpp.

References qt_message(), qt_message_fatal(), 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 964 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), and QtFatalMsg.

+ Here is the call graph for this function:

◆ 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 882 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), qt_message(), qt_message_fatal(), QT_TERMINATE_ON_EXCEPTION, QtCriticalMsg, 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 601 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 615 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), QLoggingCategory::isInfoEnabled(), and QtInfoMsg.

+ Here is the call graph for this function:

◆ 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 548 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), isFatal(), QLoggingCategory::isInfoEnabled(), qt_message(), qt_message_fatal(), 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 534 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 717 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 648 of file qlogging.cpp.

References isFatal(), qt_message(), qt_message_fatal(), and QtWarningMsg.

Referenced by dumpwarning(), 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 730 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), QLoggingCategory::isWarningEnabled(), and QtWarningMsg.

+ Here is the call graph for this function:

◆ 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 666 of file qlogging.cpp.

References QMessageLogContext::category, QLoggingCategory::categoryName(), isFatal(), QLoggingCategory::isWarningEnabled(), qt_message(), qt_message_fatal(), 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:

\inmodule QtCore
const QLoggingCategory & category()
[1]

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 88 of file qlogging.h.


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