diff options
Diffstat (limited to 'src/corelib/global/qlogging.h')
-rw-r--r-- | src/corelib/global/qlogging.h | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index b0d8d37a37..b4ec1a1235 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -1,14 +1,18 @@ // Copyright (C) 2016 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only -#include <QtCore/qglobal.h> - #ifndef QLOGGING_H #define QLOGGING_H +#include <QtCore/qtclasshelpermacros.h> +#include <QtCore/qtconfigmacros.h> +#include <QtCore/qtcoreexports.h> +#include <QtCore/qcontainerfwd.h> + #if 0 // header is automatically included in qglobal.h #pragma qt_no_master_include +#pragma qt_class(QtLogging) #endif QT_BEGIN_NAMESPACE @@ -21,24 +25,30 @@ QT_BEGIN_NAMESPACE class QDebug; class QNoDebug; + enum QtMsgType { QtDebugMsg, + QT7_ONLY(QtInfoMsg,) QtWarningMsg, QtCriticalMsg, QtFatalMsg, - QtInfoMsg, - QtSystemMsg = QtCriticalMsg + QT6_ONLY(QtInfoMsg,) +#if QT_DEPRECATED_SINCE(6, 7) + QtSystemMsg Q_DECL_ENUMERATOR_DEPRECATED_X("Use QtCriticalMsg instead.") = QtCriticalMsg +#endif }; +class QInternalMessageLogContext; class QMessageLogContext { Q_DISABLE_COPY(QMessageLogContext) public: + static constexpr int CurrentVersion = 2; constexpr QMessageLogContext() noexcept = default; constexpr QMessageLogContext(const char *fileName, int lineNumber, const char *functionName, const char *categoryName) noexcept : line(lineNumber), file(fileName), function(functionName), category(categoryName) {} - int version = 2; + int version = CurrentVersion; int line = 0; const char *file = nullptr; const char *function = nullptr; @@ -47,12 +57,18 @@ public: private: QMessageLogContext ©ContextFrom(const QMessageLogContext &logContext) noexcept; + friend class QInternalMessageLogContext; friend class QMessageLogger; - friend class QDebug; }; class QLoggingCategory; +#if defined(Q_CC_MSVC_ONLY) +# define QT_MESSAGE_LOGGER_NORETURN +#else +# define QT_MESSAGE_LOGGER_NORETURN Q_NORETURN +#endif + class Q_CORE_EXPORT QMessageLogger { Q_DISABLE_COPY(QMessageLogger) @@ -71,6 +87,8 @@ public: void warning(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); Q_DECL_COLD_FUNCTION void critical(const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); + QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION + void fatal(const char *msg, ...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); typedef const QLoggingCategory &(*CategoryFunction)(); @@ -86,12 +104,10 @@ public: void critical(const QLoggingCategory &cat, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); Q_DECL_COLD_FUNCTION void critical(CategoryFunction catFunc, const char *msg, ...) const Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); - -#ifndef Q_CC_MSVC - Q_NORETURN -#endif - Q_DECL_COLD_FUNCTION - void fatal(const char *msg, ...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(2, 3); + QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION + void fatal(const QLoggingCategory &cat, const char *msg, ...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); + QT_MESSAGE_LOGGER_NORETURN Q_DECL_COLD_FUNCTION + void fatal(CategoryFunction catFunc, const char *msg, ...) const noexcept Q_ATTRIBUTE_FORMAT_PRINTF(3, 4); #ifndef QT_NO_DEBUG_STREAM QDebug debug() const; @@ -112,6 +128,12 @@ public: QDebug critical(const QLoggingCategory &cat) const; Q_DECL_COLD_FUNCTION QDebug critical(CategoryFunction catFunc) const; + Q_DECL_COLD_FUNCTION + QDebug fatal() const; + Q_DECL_COLD_FUNCTION + QDebug fatal(const QLoggingCategory &cat) const; + Q_DECL_COLD_FUNCTION + QDebug fatal(CategoryFunction catFunc) const; QNoDebug noDebug() const noexcept; #endif // QT_NO_DEBUG_STREAM @@ -120,6 +142,8 @@ private: QMessageLogContext context; }; +#undef QT_MESSAGE_LOGGER_NORETURN + #if !defined(QT_MESSAGELOGCONTEXT) && !defined(QT_NO_MESSAGELOGCONTEXT) # if defined(QT_NO_DEBUG) # define QT_NO_MESSAGELOGCONTEXT |