From 7defc056d69a55ec9d5749f84e7dab84ed8c6c10 Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Mon, 3 Mar 2014 13:12:02 +0200 Subject: [PATCH] qtd3dservice: Add verbosity option This adds control over the logging level, as done in related tools winrtrunner and windeployqt. Change-Id: If8de677c4435bac55cbecafaaf60e642a36325a5 Reviewed-by: Oliver Wolff --- src/qtd3dservice/main.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/qtd3dservice/main.cpp b/src/qtd3dservice/main.cpp index 03d21ef..aac8c56 100644 --- a/src/qtd3dservice/main.cpp +++ b/src/qtd3dservice/main.cpp @@ -97,6 +97,12 @@ int main(int argc, char *argv[]) QStringLiteral("Write output to a file."), QStringLiteral("file")); parser.addOption(outputOption); + QCommandLineOption verbosityOption( + QStringLiteral("verbose"), + QLatin1String("The verbosity level of the message output " + "(0 - silent, 1 - info, 2 - debug). Defaults to 1."), + QStringLiteral("level"), QStringLiteral("1")); + parser.addOption(verbosityOption); parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); parser.addHelpOption(); @@ -112,6 +118,32 @@ int main(int argc, char *argv[]) qInstallMessageHandler(&outputFileMessageHandler); } + QStringList filterRules = QStringList() // Default logging rules + << QStringLiteral("qt.d3dservice.warning=true") + << QStringLiteral("qt.d3dservice.critical=true"); + if (parser.isSet(verbosityOption)) { + bool ok; + uint verbosity = parser.value(verbosityOption).toUInt(&ok); + if (!ok || verbosity > 2) { + qCCritical(lcD3DService) << "Incorrect value specified for verbosity."; + parser.showHelp(1); + } + switch (verbosity) { + case 2: // Enable debug print + filterRules.append(QStringLiteral("qt.d3dservice.debug=true")); + break; + case 1: // Remove warnings + filterRules.removeFirst(); + // fall through + case 0: // Silent + filterRules.removeFirst(); + // fall through + default: // Impossible + break; + } + } + QLoggingCategory::setFilterRules(filterRules.join(QLatin1Char('\n'))); + const bool installSet = parser.isSet(installOption); const bool removeSet = parser.isSet(removeOption); const bool registerSet = parser.isSet(registerOption); -- 2.7.4