diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2022-05-30 14:52:03 +0200 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2022-06-30 11:23:36 +0200 |
commit | a9038a6cc6ba79feefa38213b89d9b5ce73cb12d (patch) | |
tree | 280ccc9682fc37d6914cf58130b4f728dc5fb236 /tools/qmltc/main.cpp | |
parent | 10fa5f6bfe07c26e33e9284bdec753fde0436fc2 (diff) |
QQmlJSLogger: Switch to an ID based system
This change makes qmljslogger use an ID based system for categorizing
logging entries instead of using an enum. This allows plugins to
register their own logging categories after the fact.
It's also necessary for us to later show the warning ID when
printing warnings and for creating documentation for each ID entry.
Currently not every ID maps cleanly to only one type of warning,
this has to be cleaned up in a follow-up change.
Task-number: QTBUG-103453
Change-Id: I4cac6be7ca165b938e0ea032d077823bf17baf75
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tools/qmltc/main.cpp')
-rw-r--r-- | tools/qmltc/main.cpp | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/tools/qmltc/main.cpp b/tools/qmltc/main.cpp index cf47943034..6afa5a5fc0 100644 --- a/tools/qmltc/main.cpp +++ b/tools/qmltc/main.cpp @@ -30,17 +30,12 @@ using namespace Qt::StringLiterals; void setupLogger(QQmlJSLogger &logger) // prepare logger to work with compiler { - const QSet<QQmlJSLoggerCategory> exceptions { - Log_ControlsSanity, // this category is just weird - Log_UnusedImport, // not critical - }; - - for (int i = 0; i <= static_cast<int>(QQmlJSLoggerCategory_Last); ++i) { - const auto c = static_cast<QQmlJSLoggerCategory>(i); - if (exceptions.contains(c)) + for (const QQmlJSLogger::Category &category : logger.categories()) { + if (category == qmlControlsSanity // this category is just weird + || category == qmlUnusedImports) continue; - logger.setCategoryLevel(c, QtCriticalMsg); - logger.setCategoryIgnored(c, false); + logger.setCategoryLevel(category.id(), QtCriticalMsg); + logger.setCategoryIgnored(category.id(), false); } } @@ -227,9 +222,9 @@ int main(int argc, char **argv) QList<QQmlJS::DiagnosticMessage> warnings = importer.takeGlobalWarnings(); if (!warnings.isEmpty()) { - logger.log(QStringLiteral("Type warnings occurred while compiling file:"), Log_Import, + logger.log(QStringLiteral("Type warnings occurred while compiling file:"), qmlImport, QQmlJS::SourceLocation()); - logger.processMessages(warnings, Log_Import); + logger.processMessages(warnings, qmlImport); // Log_Import is critical for the compiler return EXIT_FAILURE; } |