Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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 72 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 76 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 77 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.

See also
QLoggingCategory

Definition at line 79 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 730 of file qlogging.cpp.

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

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

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

◆ debug() [1/6]

QDebug QMessageLogger::debug ( ) const

Logs a debug message using a QDebug stream.

See also
qDebug(), QDebug

Definition at line 436 of file qlogging.cpp.

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

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

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

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

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

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

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

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

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

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

◆ noDebug() [1/2]

QNoDebug QMessageLogger::noDebug ( ...) const
inlinenoexcept

◆ noDebug() [2/2]

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

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

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

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

Member Data Documentation

◆ 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
See also
QLoggingCategory

Definition at line 93 of file qlogging.h.


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