diff options
Diffstat (limited to 'src/corelib/global/qlogging.h')
-rw-r--r-- | src/corelib/global/qlogging.h | 88 |
1 files changed, 39 insertions, 49 deletions
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h index 2794c747da..aa0ab93a2d 100644 --- a/src/corelib/global/qlogging.h +++ b/src/corelib/global/qlogging.h @@ -1,50 +1,18 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtCore/qglobal.h> +// 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 #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 @@ -57,24 +25,29 @@ QT_BEGIN_NAMESPACE class QDebug; class QNoDebug; + enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtInfoMsg, - QtSystemMsg = QtCriticalMsg +#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; @@ -83,12 +56,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) @@ -107,6 +86,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)(); @@ -122,12 +103,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; @@ -148,6 +127,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 @@ -156,6 +141,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 @@ -208,5 +195,8 @@ Q_CORE_EXPORT void qSetMessagePattern(const QString &messagePattern); Q_CORE_EXPORT QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, const QString &buf); +Q_DECL_COLD_FUNCTION +Q_CORE_EXPORT QString qt_error_string(int errorCode = -1); + QT_END_NAMESPACE #endif // QLOGGING_H |