diff options
-rw-r--r-- | src/libs/installer/componentchecker.cpp | 3 | ||||
-rw-r--r-- | src/libs/installer/componentchecker.h | 4 | ||||
-rw-r--r-- | src/libs/installer/globals.cpp | 18 | ||||
-rw-r--r-- | src/libs/installer/globals.h | 4 | ||||
-rw-r--r-- | src/libs/installer/packagemanagercore_p.cpp | 3 | ||||
-rw-r--r-- | src/sdk/commandlineparser.cpp | 10 | ||||
-rw-r--r-- | src/sdk/constants.h | 1 | ||||
-rw-r--r-- | src/sdk/installerbase.cpp | 17 |
8 files changed, 47 insertions, 13 deletions
diff --git a/src/libs/installer/componentchecker.cpp b/src/libs/installer/componentchecker.cpp index 2b806a5b4..33e78b008 100644 --- a/src/libs/installer/componentchecker.cpp +++ b/src/libs/installer/componentchecker.cpp @@ -37,11 +37,10 @@ #include "component.h" #include "constants.h" #include "packagemanagercore.h" +#include "globals.h" namespace QInstaller { -Q_LOGGING_CATEGORY(componentChecker, "ifw.componentChecker") - QStringList ComponentChecker::checkComponent(Component *component) { QStringList checkResult; diff --git a/src/libs/installer/componentchecker.h b/src/libs/installer/componentchecker.h index 252a04f6c..84c4e3d14 100644 --- a/src/libs/installer/componentchecker.h +++ b/src/libs/installer/componentchecker.h @@ -37,12 +37,8 @@ #include "installer_global.h" #include <QCoreApplication> -#include <QLoggingCategory> - namespace QInstaller { -Q_DECLARE_LOGGING_CATEGORY(componentChecker) - class Component; class INSTALLER_EXPORT ComponentChecker diff --git a/src/libs/installer/globals.cpp b/src/libs/installer/globals.cpp index 05e19304e..43e5b4365 100644 --- a/src/libs/installer/globals.cpp +++ b/src/libs/installer/globals.cpp @@ -33,8 +33,24 @@ **************************************************************************/ #include "globals.h" +const char IFW_COMPONENT_CHECKER[] = "ifw.componentChecker"; + +namespace QInstaller +{ + +Q_LOGGING_CATEGORY(lcComponentChecker, IFW_COMPONENT_CHECKER) + Q_GLOBAL_STATIC_WITH_ARGS(QRegExp, staticCommaRegExp, (QLatin1String("\\b(,|, )\\b"))); -QRegExp QInstaller::commaRegExp() +QRegExp commaRegExp() { return *staticCommaRegExp(); } + +QStringList loggingCategories() +{ + static QStringList categories = QStringList() << QLatin1String(IFW_COMPONENT_CHECKER); + return categories; +} + +} // namespace QInstaller + diff --git a/src/libs/installer/globals.h b/src/libs/installer/globals.h index 4df5878b9..3d6461690 100644 --- a/src/libs/installer/globals.h +++ b/src/libs/installer/globals.h @@ -37,10 +37,14 @@ #include "installer_global.h" #include <QRegExp> +#include <QLoggingCategory> namespace QInstaller { +Q_DECLARE_LOGGING_CATEGORY(lcComponentChecker) + QRegExp INSTALLER_EXPORT commaRegExp(); +QStringList INSTALLER_EXPORT loggingCategories(); } // QInstaller diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index 9fef0575a..f318a47bb 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -53,6 +53,7 @@ #include "installercalculator.h" #include "uninstallercalculator.h" #include "componentchecker.h" +#include "globals.h" #include "kdselfrestarter.h" #include "kdupdaterfiledownloaderfactory.h" @@ -395,7 +396,7 @@ bool PackageManagerCorePrivate::buildComponentTree(QHash<QString, Component*> &c foreach (QInstaller::Component *component, components) { const QStringList warnings = ComponentChecker::checkComponent(component); foreach (const QString &warning, warnings) - qCWarning(componentChecker) << warning; + qCWarning(lcComponentChecker) << warning; } } catch (const Error &error) { clearAllComponentLists(); diff --git a/src/sdk/commandlineparser.cpp b/src/sdk/commandlineparser.cpp index 23e9a5dfc..abf8abea6 100644 --- a/src/sdk/commandlineparser.cpp +++ b/src/sdk/commandlineparser.cpp @@ -35,6 +35,7 @@ #include "commandlineparser.h" #include "constants.h" +#include "globals.h" namespace CommandLineOptions { const char KeyValue[] = "Key=Value"; @@ -76,6 +77,15 @@ CommandLineParser::CommandLineParser() m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::ShowVirtualComponents), QLatin1String("Show virtual components in installer and package manager."))); + m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::LoggingRules), + QLatin1String("Enables logging according to passed rules. " + "Comma separated logging rules have the following syntax: " + "loggingCategory=true/false. " + "Passing empty logging rules enables all logging categories. " + "The following logging categories are available:\n") + + QInstaller::loggingCategories().join(QLatin1Char('\n')), + QLatin1String("rules"))); + m_parser.addOption(QCommandLineOption(QLatin1String(CommandLineOptions::CreateLocalRepository), QLatin1String("Create a local repository inside the installation directory. This option " "has no effect on online installers."))); diff --git a/src/sdk/constants.h b/src/sdk/constants.h index 089a3b6d4..db3f8af20 100644 --- a/src/sdk/constants.h +++ b/src/sdk/constants.h @@ -50,6 +50,7 @@ const char Updater[] = "updater"; const char ManagePackages[] = "manage-packages"; const char NoForceInstallation[] = "no-force-installations"; const char ShowVirtualComponents[] = "show-virtual-components"; +const char LoggingRules[] = "logging-rules"; const char CreateLocalRepository[] = "create-local-repository"; const char AddRepository[] = "addRepository"; const char AddTmpRepository[] = "addTempRepository"; diff --git a/src/sdk/installerbase.cpp b/src/sdk/installerbase.cpp index 7d0b4c58e..cff394e78 100644 --- a/src/sdk/installerbase.cpp +++ b/src/sdk/installerbase.cpp @@ -75,8 +75,6 @@ InstallerBase::~InstallerBase() int InstallerBase::run() { - QLoggingCategory::setFilterRules(QLatin1String("ifw.componentChecker = false")); - KDRunOnceChecker runCheck(qApp->applicationDirPath() + QLatin1String("/lockmyApp1234865.lock")); if (runCheck.isRunning(KDRunOnceChecker::ConditionFlag::Lockfile)) { // It is possible to install an application and thus the maintenance tool into a @@ -108,14 +106,23 @@ int InstallerBase::run() QInstaller::BinaryContent::readBinaryContent(&binary, &oldOperations, &manager, &magicMarker, cookie); + CommandLineParser parser; + parser.parse(arguments()); + + QString loggingRules(QLatin1String("ifw.* = false")); // disable all by default if (QInstaller::isVerbose()) { qDebug() << "Language:" << QLocale().uiLanguages().value(0, QLatin1String("No UI language set")).toUtf8().constData(); qDebug() << "Arguments: " << arguments().join(QLatin1String(", ")).toUtf8().constData(); - } - CommandLineParser parser; - parser.parse(arguments()); + loggingRules = QString(); // enable all in verbose mode + if (parser.isSet(QLatin1String(CommandLineOptions::LoggingRules))) { + loggingRules = parser.value(QLatin1String(CommandLineOptions::LoggingRules)) + .split(QLatin1Char(','), QString::SkipEmptyParts) + .join(QLatin1Char('\n')); // take rules from command line + } + } + QLoggingCategory::setFilterRules(loggingRules); SDKApp::registerMetaResources(manager.collectionByName("QResources")); if (parser.isSet(QLatin1String(CommandLineOptions::StartClient))) { |