diff options
Diffstat (limited to 'sources/shiboken2/ApiExtractor/reporthandler.cpp')
-rw-r--r-- | sources/shiboken2/ApiExtractor/reporthandler.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/sources/shiboken2/ApiExtractor/reporthandler.cpp b/sources/shiboken2/ApiExtractor/reporthandler.cpp index c0c323029..2c6ab444b 100644 --- a/sources/shiboken2/ApiExtractor/reporthandler.cpp +++ b/sources/shiboken2/ApiExtractor/reporthandler.cpp @@ -35,7 +35,7 @@ #include <cstdarg> #include <cstdio> -#if _WINDOWS || NOCOLOR +#if defined(_WINDOWS) || defined(NOCOLOR) #define COLOR_END "" #define COLOR_WHITE "" #define COLOR_YELLOW "" @@ -58,10 +58,16 @@ static int m_step_warning = 0; static QElapsedTimer m_timer; Q_LOGGING_CATEGORY(lcShiboken, "qt.shiboken") +Q_LOGGING_CATEGORY(lcShibokenDoc, "qt.shiboken.doc") void ReportHandler::install() { qInstallMessageHandler(ReportHandler::messageOutput); + startTimer(); +} + +void ReportHandler::startTimer() +{ m_timer.start(); } @@ -75,6 +81,20 @@ void ReportHandler::setDebugLevel(ReportHandler::DebugLevel level) m_debugLevel = level; } +bool ReportHandler::setDebugLevelFromArg(const QString &level) +{ + bool result = true; + if (level == QLatin1String("sparse")) + ReportHandler::setDebugLevel(ReportHandler::SparseDebug); + else if (level == QLatin1String("medium")) + ReportHandler::setDebugLevel(ReportHandler::MediumDebug); + else if (level == QLatin1String("full")) + ReportHandler::setDebugLevel(ReportHandler::FullDebug); + else + result = false; + return result; +} + int ReportHandler::suppressedCount() { return m_suppressedCount; @@ -102,13 +122,19 @@ 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")); if (type == QtWarningMsg) { if (m_silent || m_reportedWarnings.contains(text)) return; - const TypeDatabase *db = TypeDatabase::instance(); - if (db && db->isSuppressedWarning(text)) { - ++m_suppressedCount; - return; + if (auto db = TypeDatabase::instance()) { + const bool suppressed = fileLocationPos >= 0 + ? db->isSuppressedWarning(text.midRef(fileLocationPos + 2)) + : db->isSuppressedWarning(text); + if (suppressed) { + ++m_suppressedCount; + return; + } } ++m_warningCount; ++m_step_warning; @@ -117,7 +143,11 @@ 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(text); + // Replace file location tab by space + if (fileLocationPos >= 0) + message[prefixLength + fileLocationPos + 1] = QLatin1Char(' '); fprintf(stderr, "%s\n", qPrintable(qFormatLogMessage(type, context, message))); } |