7#include <QtCore/qtclasshelpermacros.h>
8#include <QtCore/qtconfigmacros.h>
9#include <QtCore/qtcoreexports.h>
10#include <QtCore/qcontainerfwd.h>
14#pragma qt_no_master_include
15#pragma qt_class(QtLogging)
21
22
23
24
36#if QT_DEPRECATED_SINCE(6
, 7
)
48 constexpr QMessageLogContext(
const char *fileName,
int lineNumber,
const char *functionName,
const char *categoryName)
noexcept
53 const char *
file =
nullptr;
61 friend class QMessageLogger;
64class QLoggingCategory;
66#if defined(Q_CC_MSVC_ONLY)
67# define QT_MESSAGE_LOGGER_NORETURN
69# define QT_MESSAGE_LOGGER_NORETURN Q_NORETURN
74 Q_DISABLE_COPY(QMessageLogger)
76 constexpr QMessageLogger() : context() {}
77 constexpr QMessageLogger(
const char *file,
int line,
const char *function)
78 : context(file, line, function,
"default") {}
79 constexpr QMessageLogger(
const char *file,
int line,
const char *function,
const char *category)
80 : context(file, line, function, category) {}
82 void debug(
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
83 void noDebug(
const char *, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3)
85 void info(
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
87 void warning(
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
89 void critical(
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
91 void fatal(
const char *msg, ...)
const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(2, 3);
93 typedef const QLoggingCategory &(*CategoryFunction)();
95 void debug(
const QLoggingCategory &cat,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
96 void debug(CategoryFunction catFunc,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
97 void info(
const QLoggingCategory &cat,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
98 void info(CategoryFunction catFunc,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
100 void warning(
const QLoggingCategory &cat,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
102 void warning(CategoryFunction catFunc,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
104 void critical(
const QLoggingCategory &cat,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
106 void critical(CategoryFunction catFunc,
const char *msg, ...)
const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
108 void fatal(
const QLoggingCategory &cat,
const char *msg, ...)
const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
110 void fatal(CategoryFunction catFunc,
const char *msg, ...)
const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(3, 4);
112#ifndef QT_NO_DEBUG_STREAM
113 QDebug
debug()
const;
114 QDebug
debug(
const QLoggingCategory &cat)
const;
115 QDebug
debug(CategoryFunction catFunc)
const;
117 QDebug
info(
const QLoggingCategory &cat)
const;
118 QDebug
info(CategoryFunction catFunc)
const;
122 QDebug warning(
const QLoggingCategory &cat)
const;
124 QDebug warning(CategoryFunction catFunc)
const;
128 QDebug critical(
const QLoggingCategory &cat)
const;
130 QDebug critical(CategoryFunction catFunc)
const;
134 QDebug fatal(
const QLoggingCategory &cat)
const;
136 QDebug fatal(CategoryFunction catFunc)
const;
139# if QT_CORE_REMOVED_SINCE(6
, 10
)
140 QNoDebug noDebug()
const noexcept;
145 QMessageLogContext context;
148#undef QT_MESSAGE_LOGGER_NORETURN
150#if !defined(QT_MESSAGELOGCONTEXT) && !defined(QT_NO_MESSAGELOGCONTEXT)
151# if defined(QT_NO_DEBUG)
152# define QT_NO_MESSAGELOGCONTEXT
154# define QT_MESSAGELOGCONTEXT
159 #define QT_MESSAGELOG_FILE static_cast<const char *>(__FILE__)
160 #define QT_MESSAGELOG_LINE __LINE__
161 #define QT_MESSAGELOG_FUNC static_cast<const char *>(Q_FUNC_INFO)
163 #define QT_MESSAGELOG_FILE nullptr
164 #define QT_MESSAGELOG_LINE 0
165 #define QT_MESSAGELOG_FUNC nullptr
174Q_CORE_EXPORT Q_DECL_COLD_FUNCTION
void qErrnoWarning(
int code,
const char *msg, ...);
175Q_CORE_EXPORT Q_DECL_COLD_FUNCTION
void qErrnoWarning(
const char *msg, ...);
177#define QT_NO_QDEBUG_MACRO while (false) QMessageLogger().noDebug
179#if defined(QT_NO_DEBUG_OUTPUT)
181# define qDebug QT_NO_QDEBUG_MACRO
183#if defined(QT_NO_INFO_OUTPUT)
185# define qInfo QT_NO_QDEBUG_MACRO
187#if defined(QT_NO_WARNING_OUTPUT)
189# define qWarning QT_NO_QDEBUG_MACRO
190# define qErrnoWarning QT_NO_QDEBUG_MACRO
194 const QString &message);
197Q_CORE_EXPORT QtMessageHandler qInstallMessageHandler(QtMessageHandler);
200Q_CORE_EXPORT
QString qFormatLogMessage(QtMsgType type,
const QMessageLogContext &context,
204Q_CORE_EXPORT QString qt_error_string(
int errorCode = -1);
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
static Q_CONSTINIT thread_local bool msgHandlerGrabbed
static const char ifCriticalTokenC[]
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 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 const char timeTokenC[]
static bool is_fatal_count_down(QAtomicInt &n)
static const char qthreadptrTokenC[]
static const char fileTokenC[]
static const char ifDebugTokenC[]
static const char ifFatalTokenC[]
static const char categoryTokenC[]
static const char lineTokenC[]
static const char typeTokenC[]
static const char ifCategoryTokenC[]
static int checked_var_value(const char *varname)
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 const char backtraceTokenC[]
static const char functionTokenC[]
static const char ifWarningTokenC[]
static const char appnameTokenC[]
static bool isFatal(QtMsgType msgType)
static const char ifInfoTokenC[]
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.
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
Q_CORE_EXPORT Q_DECL_COLD_FUNCTION void qErrnoWarning(int code, const char *msg,...)
Q_CORE_EXPORT Q_DECL_COLD_FUNCTION void qErrnoWarning(const char *msg,...)
#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