diff options
author | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2015-04-23 12:00:17 +0200 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@theqtcompany.com> | 2015-04-24 12:57:10 +0000 |
commit | 2554ccb7ba4ef3103411e38b0c2d5d218217cccd (patch) | |
tree | c2ba19a0d5b834f2f5783c725dc115e3c3b4efbe /src/sdk | |
parent | 61bf0345cdc86dc4053a5c2c1c3f782b5fd970ed (diff) |
Enable logging categories as an installer option.
Now by default all categories are disabled.
They get enabled only in verbose mode.
Verbose mode enables all categories by default.
Categories can be filtered using logging-rules option.
Change-Id: I9324826a6e2d7a746e3d7369747fcd31a42b84b6
Reviewed-by: Karsten Heimrich <karsten.heimrich@theqtcompany.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src/sdk')
-rw-r--r-- | src/sdk/commandlineparser.cpp | 10 | ||||
-rw-r--r-- | src/sdk/constants.h | 1 | ||||
-rw-r--r-- | src/sdk/installerbase.cpp | 17 |
3 files changed, 23 insertions, 5 deletions
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))) { |