diff options
Diffstat (limited to 'sources/shiboken6/ApiExtractor/reporthandler.cpp')
-rw-r--r-- | sources/shiboken6/ApiExtractor/reporthandler.cpp | 72 |
1 files changed, 34 insertions, 38 deletions
diff --git a/sources/shiboken6/ApiExtractor/reporthandler.cpp b/sources/shiboken6/ApiExtractor/reporthandler.cpp index f0c5bf31e..23066ba21 100644 --- a/sources/shiboken6/ApiExtractor/reporthandler.cpp +++ b/sources/shiboken6/ApiExtractor/reporthandler.cpp @@ -1,40 +1,19 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt for Python. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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 General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** 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-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "reporthandler.h" -#include "typesystem.h" #include "typedatabase.h" + +#include "qtcompat.h" + #include <QtCore/QElapsedTimer> #include <QtCore/QSet> #include <cstring> #include <cstdarg> #include <cstdio> +using namespace Qt::StringLiterals; + #if defined(_WINDOWS) || defined(NOCOLOR) #define COLOR_END "" #define COLOR_WHITE "" @@ -54,6 +33,7 @@ static ReportHandler::DebugLevel m_debugLevel = ReportHandler::NoDebug; static QSet<QString> m_reportedWarnings; static QString m_prefix; static bool m_withinProgress = false; +static QByteArray m_progressMessage; static int m_step_warning = 0; static QElapsedTimer m_timer; @@ -84,11 +64,11 @@ void ReportHandler::setDebugLevel(ReportHandler::DebugLevel level) bool ReportHandler::setDebugLevelFromArg(const QString &level) { bool result = true; - if (level == QLatin1String("sparse")) + if (level == u"sparse") ReportHandler::setDebugLevel(ReportHandler::SparseDebug); - else if (level == QLatin1String("medium")) + else if (level == u"medium") ReportHandler::setDebugLevel(ReportHandler::MediumDebug); - else if (level == QLatin1String("full")) + else if (level == u"full") ReportHandler::setDebugLevel(ReportHandler::FullDebug); else result = false; @@ -123,7 +103,7 @@ void ReportHandler::setPrefix(const QString &p) void ReportHandler::messageOutput(QtMsgType type, const QMessageLogContext &context, const QString &text) { // Check for file location separator added by SourceLocation - int fileLocationPos = text.indexOf(QLatin1String(":\t")); + int fileLocationPos = text.indexOf(u":\t"); if (type == QtWarningMsg) { if (m_silent || m_reportedWarnings.contains(text)) return; @@ -142,12 +122,12 @@ void ReportHandler::messageOutput(QtMsgType type, const QMessageLogContext &cont } QString message = m_prefix; if (!message.isEmpty()) - message.append(QLatin1Char(' ')); - const int prefixLength = message.size(); + message.append(u' '); + const auto prefixLength = message.size(); message.append(text); // Replace file location tab by space if (fileLocationPos >= 0) - message[prefixLength + fileLocationPos + 1] = QLatin1Char(' '); + message[prefixLength + fileLocationPos + 1] = u' '; fprintf(stderr, "%s\n", qPrintable(qFormatLogMessage(type, context, message))); } @@ -168,9 +148,13 @@ void ReportHandler::startProgress(const QByteArray& str) endProgress(); m_withinProgress = true; - const auto ts = '[' + timeStamp() + ']'; - std::printf("%s %8s %-60s", qPrintable(m_prefix), ts.constData(), str.constData()); - std::fflush(stdout); + m_progressMessage = str; +} + +static void indentStdout(qsizetype n) +{ + for (qsizetype i = 0; i < n; ++i) + fputc(' ', stdout); } void ReportHandler::endProgress() @@ -179,11 +163,23 @@ void ReportHandler::endProgress() return; m_withinProgress = false; + + std::fputs(m_prefix.toUtf8().constData(), stdout); + const auto ts = timeStamp(); + if (ts.size() < 6) + indentStdout(6 - ts.size()); + std::fputs(" [", stdout); + std::fputs(ts.constData(), stdout); + std::fputs("] ", stdout); + std::fputs(m_progressMessage.constData(), stdout); + if (m_progressMessage.size() < 60) + indentStdout(60 - m_progressMessage.size()); const char *endMessage = m_step_warning == 0 ? "[" COLOR_GREEN "OK" COLOR_END "]\n" : "[" COLOR_YELLOW "WARNING" COLOR_END "]\n"; std::fputs(endMessage, stdout); std::fflush(stdout); + m_progressMessage.clear(); m_step_warning = 0; } |