8#include <QtCore/qtclasshelpermacros.h>
9#include <QtCore/qtconfigmacros.h>
10#include <QtCore/qtcoreexports.h>
11#include <QtCore/qcontainerfwd.h>
15#pragma qt_no_master_include
16#pragma qt_class(QtLogging)
22
23
24
25
37#if QT_DEPRECATED_SINCE(6
, 7
)
49 constexpr QMessageLogContext(
const char *fileName,
int lineNumber,
const char *functionName,
const char *categoryName)
noexcept
54 const char *
file =
nullptr;
62 friend class QMessageLogger;
65class QLoggingCategory;
67#if defined(Q_CC_MSVC_ONLY)
68# define QT_MESSAGE_LOGGER_NORETURN
70# define QT_MESSAGE_LOGGER_NORETURN Q_NORETURN
75 Q_DISABLE_COPY(QMessageLogger)
77 constexpr QMessageLogger() : context() {}
78 constexpr QMessageLogger(
const char *file,
int line,
const char *function)
79 : context(file, line, function,
"default") {}
80 constexpr QMessageLogger(
const char *file,
int line,
const char *function,
const char *category)
81 : context(file, line, function, category) {}
83 void debug(
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
84 void noDebug(
const char *, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3)
86 void info(
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
88 void warning(
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
90 void critical(
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
92 void fatal(
const char *msg, ...)
const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
94 typedef const QLoggingCategory &(*CategoryFunction)();
96 void debug(
const QLoggingCategory &cat,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
97 void debug(CategoryFunction catFunc,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
98 void info(
const QLoggingCategory &cat,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
99 void info(CategoryFunction catFunc,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
101 void warning(
const QLoggingCategory &cat,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
103 void warning(CategoryFunction catFunc,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
105 void critical(
const QLoggingCategory &cat,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
107 void critical(CategoryFunction catFunc,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
109 void fatal(
const QLoggingCategory &cat,
const char *msg, ...)
const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
111 void fatal(CategoryFunction catFunc,
const char *msg, ...)
const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
113#ifndef QT_NO_DEBUG_STREAM
114 QDebug
debug()
const;
115 QDebug
debug(
const QLoggingCategory &cat)
const;
116 QDebug
debug(CategoryFunction catFunc)
const;
118 QDebug
info(
const QLoggingCategory &cat)
const;
119 QDebug
info(CategoryFunction catFunc)
const;
123 QDebug warning(
const QLoggingCategory &cat)
const;
125 QDebug warning(CategoryFunction catFunc)
const;
129 QDebug critical(
const QLoggingCategory &cat)
const;
131 QDebug critical(CategoryFunction catFunc)
const;
135 QDebug fatal(
const QLoggingCategory &cat)
const;
137 QDebug fatal(CategoryFunction catFunc)
const;
140# if QT_CORE_REMOVED_SINCE(6
, 10
)
141 QNoDebug noDebug()
const noexcept;
146 QMessageLogContext context;
149#undef QT_MESSAGE_LOGGER_NORETURN
151#if !defined(QT_MESSAGELOGCONTEXT) && !defined(QT_NO_MESSAGELOGCONTEXT)
152# if defined(QT_NO_DEBUG)
153# define QT_NO_MESSAGELOGCONTEXT
155# define QT_MESSAGELOGCONTEXT
160 #define QT_MESSAGELOG_FILE static_cast<const char *>(__FILE__)
161 #define QT_MESSAGELOG_LINE __LINE__
162 #define QT_MESSAGELOG_FUNC static_cast<const char *>(Q_FUNC_INFO)
164 #define QT_MESSAGELOG_FILE nullptr
165 #define QT_MESSAGELOG_LINE 0
166 #define QT_MESSAGELOG_FUNC nullptr
175Q_CORE_EXPORT Q_DECL_COLD_FUNCTION
void qErrnoWarning(
int code,
const char *msg, ...);
176Q_CORE_EXPORT Q_DECL_COLD_FUNCTION
void qErrnoWarning(
const char *msg, ...);
178#define QT_NO_QDEBUG_MACRO while (false) QMessageLogger().noDebug
180#if defined(QT_NO_DEBUG_OUTPUT)
182# define qDebug QT_NO_QDEBUG_MACRO
184#if defined(QT_NO_INFO_OUTPUT)
186# define qInfo QT_NO_QDEBUG_MACRO
188#if defined(QT_NO_WARNING_OUTPUT)
190# define qWarning QT_NO_QDEBUG_MACRO
191# define qErrnoWarning QT_NO_QDEBUG_MACRO
195 const QString &message);
198Q_CORE_EXPORT QtMessageHandler qInstallMessageHandler(QtMessageHandler);
201Q_CORE_EXPORT
QString qFormatLogMessage(QtMsgType type,
const QMessageLogContext &context,
205Q_CORE_EXPORT QString qt_error_string(
int errorCode = -1);
int initFrom(const QMessageLogContext &logContext)
void populateBacktrace(int frameCount)
constexpr QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName) noexcept
constexpr QMessageLogContext() noexcept=default
QDebug debug(CategoryFunction catFunc) const
QDebug debug(const QLoggingCategory &cat) const
Logs a debug message into category cat using a QDebug stream.
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 info(const QLoggingCategory &cat) const
Logs an informational message into the category cat using a QDebug stream.
QDebug info() const
Logs an informational message using a QDebug stream.
QNoDebug noDebug(...) const noexcept
QDebug info(CategoryFunction catFunc) const
\macro QT_RESTRICTED_CAST_FROM_ASCII
static const char ifCriticalTokenC[]
static bool grabMessageHandler()
void qt_message_output(QtMsgType msgType, const QMessageLogContext &context, const QString &message)
static const char emptyTokenC[]
static Q_NEVER_INLINE void qt_message(QtMsgType msgType, const QMessageLogContext &context, const char *msg, va_list ap)
static void preformattedMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &formattedMessage)
static bool systemHasStderr()
Returns true if writing to stderr is supported.
static const char endifTokenC[]
static bool isDefaultCategory(const char *category)
static const char messageTokenC[]
static bool qt_append_thread_name_to(QString &message)
static constexpr SystemMessageSink systemMessageSink
static void qt_maybe_message_fatal(QtMsgType, const QMessageLogContext &context, String &&message)
\inmodule QtCore \title Qt Logging Types
#define HANDLE_IF_TOKEN(LEVEL)
Q_DECLARE_TYPEINFO(QMessagePattern::BacktraceParams, Q_RELOCATABLE_TYPE)
static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &buf)
static const char timeTokenC[]
static bool isFatalCountDown(const char *varname, QBasicAtomicInt &n)
void qErrnoWarning(int code, const char *msg,...)
static const char qthreadptrTokenC[]
static const char fileTokenC[]
static const char ifDebugTokenC[]
static const char ifFatalTokenC[]
static const char categoryTokenC[]
static void stderr_message_handler(QtMsgType type, const QMessageLogContext &context, const QString &formattedMessage)
static const char lineTokenC[]
static const char typeTokenC[]
static void ungrabMessageHandler()
static void copyInternalContext(QInternalMessageLogContext *self, const QMessageLogContext &logContext) noexcept
static const char ifCategoryTokenC[]
static int checked_var_value(const char *varname)
static const char threadnameTokenC[]
static const char pidTokenC[]
Q_TRACE_POINT(qtcore, qt_message_print, int type, const char *category, const char *function, const char *file, int line, const QString &message)
static const char threadidTokenC[]
static QString formatLogMessage(QtMsgType type, const QMessageLogContext &context, const QString &str)
static Q_CONSTINIT bool msgHandlerGrabbed
static const char backtraceTokenC[]
void qErrnoWarning(const char *msg,...)
static const char functionTokenC[]
static const char ifWarningTokenC[]
static const char appnameTokenC[]
static bool isFatal(QtMsgType msgType)
static const char ifInfoTokenC[]
QtMessageHandler qInstallMessageHandler(QtMessageHandler h)
static void qt_message_print(QtMsgType, const QMessageLogContext &context, const QString &message)
static bool stderrHasConsoleAttached()
Returns true if writing to stderr will end up in a console/terminal visible to the user.
void qSetMessagePattern(const QString &pattern)
Combined button and popup list for selecting options.
bool shouldLogToStderr()
Returns true if logging stderr should be ensured.
Q_CORE_EXPORT QDebug operator<<(QDebug debug, QDir::Filters filters)
#define QT_MESSAGELOG_FUNC
#define QT_MESSAGELOG_FILE
#define QT_MESSAGE_LOGGER_NORETURN
#define QT_MESSAGELOG_LINE
Q_CORE_EXPORT void qSetMessagePattern(const QString &messagePattern)
#define QT_MESSAGELOGCONTEXT
Q_CORE_EXPORT void qt_message_output(QtMsgType, const QMessageLogContext &context, const QString &message)
void(* QtMessageHandler)(QtMsgType, const QMessageLogContext &, const QString &)
QString backtraceSeparator
void setPattern(const QString &pattern)
std::unique_ptr< std::unique_ptr< const char[]>[]> literals
std::chrono::steady_clock::time_point appStartTime
std::unique_ptr< const char *[]> tokens
QList< QString > timeArgs