From fba4ca0ec11d653791a7f6fb1e1d5e06103aeebb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 22 Sep 2021 19:31:32 -0700 Subject: QLibrary/QPlugin/QFactoryLoader: convert to category logging This adds three categories: - qt.core.library - qt.core.plugin.loader - qt.core.plugin.factoryloader plus the "qt.core.plugin.elfparser" category (only available in developer builds). All three use the new Q_LOGGING_CATEGORY_WITH_ENV_OVERRIDE technique which enables their debugging if the QT_DEBUG_PLUGINS=1 variable is set. As a consequence, some warnings were downgraded to debug messages. I've only left as warnings situations where a real problem occurred, since they now get printed by default: failures to open or mmap a file, corrupt plugin metadata (but not scan of non-plugins), use of QPluginLoader with a static build of Qt. Drive-by update of some messages to make them prettier and/or use qUtf16Printable(). Change-Id: I3eb1bd30e0124f89a052fffd16a752acfe89c19e Reviewed-by: Kai Koehne --- src/corelib/plugin/qpluginloader.cpp | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/corelib/plugin/qpluginloader.cpp') diff --git a/src/corelib/plugin/qpluginloader.cpp b/src/corelib/plugin/qpluginloader.cpp index eca85eb82ee..fb691421496 100644 --- a/src/corelib/plugin/qpluginloader.cpp +++ b/src/corelib/plugin/qpluginloader.cpp @@ -271,8 +271,6 @@ static QString locatePlugin(const QString& fileName) const auto baseName = QStringView{fileName}.mid(slash + 1); const auto basePath = isAbsolute ? QStringView() : QStringView{fileName}.left(slash + 1); // keep the '/' - const bool debug = qt_debug_component(); - QStringList paths; if (isAbsolute) { paths.append(fileName.left(slash)); // don't include the '/' @@ -287,22 +285,19 @@ static QString locatePlugin(const QString& fileName) { QString pluginPath = basePath + prefix + baseName + suffix; const QString fn = path + QLatin1String("/lib") + pluginPath.replace(QLatin1Char('/'), QLatin1Char('_')); - if (debug) - qDebug() << "Trying..." << fn; + qCDebug(qt_lcDebugPlugins) << "Trying..." << fn; if (QFileInfo(fn).isFile()) return fn; } #endif const QString fn = path + QLatin1Char('/') + basePath + prefix + baseName + suffix; - if (debug) - qDebug() << "Trying..." << fn; + qCDebug(qt_lcDebugPlugins) << "Trying..." << fn; if (QFileInfo(fn).isFile()) return fn; } } } - if (debug) - qDebug() << fileName << "not found"; + qCDebug(qt_lcDebugPlugins) << fileName << "not found"; return QString(); } #endif @@ -347,11 +342,8 @@ void QPluginLoader::setFileName(const QString &fileName) d->updatePluginState(); #else - if (qt_debug_component()) { - qWarning("Cannot load %s into a statically linked Qt library.", - (const char *)QFile::encodeName(fileName)); - } - Q_UNUSED(fileName); + qCWarning(qt_lcDebugPlugins, "Cannot load '%ls' into a statically linked Qt library.", + qUtf16Printable(fileName)); #endif } -- cgit v1.2.3