aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmlcachegen/qmlcachegen.cpp
diff options
context:
space:
mode:
authorAndrei Golubev <andrei.golubev@qt.io>2022-02-03 13:45:18 +0100
committerAndrei Golubev <andrei.golubev@qt.io>2022-02-12 23:21:29 +0100
commit690b7cb6a2ff86006ed75bb0e09e35d4ceae4c8a (patch)
tree98a4a76a8d061c5c5310245bee177e1c91c652b4 /tools/qmlcachegen/qmlcachegen.cpp
parentf99b2cce65123ac419015968ef3a4f392e55ef6c (diff)
Redesign QQmlJSLogger internals
High-level goal: be able to reuse existing infrastructure "as is" to configure semantic analysis categories in tools (qmllint, qmltc, qmlsc, etc.) To achieve that, simplify the logging to always "log" something, without explicitly specifying the severity. The severity is now baked into the category (and we can extend those to cover different cases) One slight deviation is the cache generation which likes to do its own thing at present. Provide a "forced logging" option where we can specify which severify we want. The hope is that this gets removed at some point Particular list of (noteworthy) changes: * No more "thresholding" by the level (this is rarely needed and is actually questionable). Instead, we can ignore a particular category explicitly * Category levels are repurposed as category severities (at least from the high-level picture that always should've been this way) * log{Warning,Info,Critical} removed. We use category severity instead * "category error" makes zero sense so removed: if our severity is: - QtWarningMsg (qmllint), it is already an "error" - QtCriticalMsg (compilers), it is already an "error" * Align m_output and m_{infos,warnings,errors} stored information * Accept the fact that we don't support QtDebugMsg and QtFatalMsg * Additional categories added to cover for places where the same category would be both an error and not an error Task-number: QTBUG-100052 Change-Id: I3cd5d17d58be204f48428877bed053f756ac40a8 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools/qmlcachegen/qmlcachegen.cpp')
-rw-r--r--tools/qmlcachegen/qmlcachegen.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/tools/qmlcachegen/qmlcachegen.cpp b/tools/qmlcachegen/qmlcachegen.cpp
index d6869ab05b..918c83e6d6 100644
--- a/tools/qmlcachegen/qmlcachegen.cpp
+++ b/tools/qmlcachegen/qmlcachegen.cpp
@@ -270,19 +270,14 @@ int main(int argc, char **argv)
QQmlJSLogger logger;
// Always trigger the qFatal() on "pragma Strict" violations.
- logger.setCategoryError(Log_Compiler, true);
+ logger.setCategoryLevel(Log_Compiler, QtCriticalMsg);
// By default, we're completely silent,
// as the lcAotCompiler category default is QtFatalMsg
- if (lcAotCompiler().isDebugEnabled())
- logger.setCategoryLevel(Log_Compiler, QtDebugMsg);
- else if (lcAotCompiler().isInfoEnabled())
- logger.setCategoryLevel(Log_Compiler, QtInfoMsg);
- else if (lcAotCompiler().isWarningEnabled())
- logger.setCategoryLevel(Log_Compiler, QtWarningMsg);
- else if (lcAotCompiler().isCriticalEnabled())
- logger.setCategoryLevel(Log_Compiler, QtCriticalMsg);
- else
+ const bool loggingEnabled = lcAotCompiler().isDebugEnabled()
+ || lcAotCompiler().isInfoEnabled() || lcAotCompiler().isWarningEnabled()
+ || lcAotCompiler().isCriticalEnabled();
+ if (!loggingEnabled)
logger.setSilent(true);
QQmlJSAotCompiler cppCodeGen(
@@ -297,9 +292,9 @@ int main(int argc, char **argv)
QList<QQmlJS::DiagnosticMessage> warnings = importer.takeGlobalWarnings();
if (!warnings.isEmpty()) {
- logger.logWarning(QStringLiteral("Type warnings occurred while compiling file:"),
- Log_Import);
- logger.processMessages(warnings, QtWarningMsg, Log_Import);
+ logger.log(QStringLiteral("Type warnings occurred while compiling file:"),
+ Log_Import, QQmlJS::SourceLocation());
+ logger.processMessages(warnings, Log_Import);
}
}
} else if (inputFile.endsWith(QLatin1String(".js")) || inputFile.endsWith(QLatin1String(".mjs"))) {