winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 2f4c511a3947636efef7d821f48eb06b57eb9327
parent afe95d94c15ee4d025a982f2db7dd0a7dc8e38c0
Author: JohnMcPMS <johnmcp@microsoft.com>
Date:   Thu,  7 May 2020 16:15:25 -0700

Disable verbose logging by default (#110)


Diffstat:
Msrc/AppInstallerCLICore/Argument.cpp | 3+++
Msrc/AppInstallerCLICore/Core.cpp | 10+++++++++-
Msrc/AppInstallerCLICore/ExecutionArgs.h | 1+
Msrc/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw | 3+++
Msrc/AppInstallerRepositoryCore/SQLiteWrapper.cpp | 2+-
5 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/AppInstallerCLICore/Argument.cpp b/src/AppInstallerCLICore/Argument.cpp @@ -76,6 +76,8 @@ namespace AppInstaller::CLI return Argument{ "plain", None, Args::Type::PlainStyle, Resources::GetInstance().ResolveWingetString(L"PlainArgumentDescription").c_str(), ArgumentType::Flag, Visibility::Hidden }; case Args::Type::Force: return Argument{ "force", None, Args::Type::Force, Resources::GetInstance().ResolveWingetString(L"ForceArgumentDescription").c_str(), ArgumentType::Flag }; + case Args::Type::VerboseLogs: + return Argument{ "verbose-logs", None, Args::Type::VerboseLogs, Resources::GetInstance().ResolveWingetString(L"VerboseLogsArgumentDescription").c_str(), ArgumentType::Flag }; default: THROW_HR(E_UNEXPECTED); } @@ -87,5 +89,6 @@ namespace AppInstaller::CLI args.push_back(ForType(Args::Type::NoVT)); args.push_back(ForType(Args::Type::RainbowStyle)); args.push_back(ForType(Args::Type::PlainStyle)); + args.push_back(ForType(Args::Type::VerboseLogs)); } } diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp @@ -45,7 +45,7 @@ namespace AppInstaller::CLI // Set output to UTF8 ConsoleOuputCPRestore utf8CP(CP_UTF8); - // Enable logging (*all* for now, TODO: add common arguments to allow control of logging) + // Enable all logging for this phase; we will update once we have the arguments Logging::Log().EnableChannel(Logging::Channel::All); Logging::Log().SetLevel(Logging::Level::Verbose); Logging::AddFileLogger(); @@ -88,7 +88,15 @@ namespace AppInstaller::CLI Logging::Telemetry().LogCommand(command->FullName()); command->ParseArguments(invocation, context.Args); + + // Change logging level to Info if Verbose not requested + if (!context.Args.Contains(Execution::Args::Type::VerboseLogs)) + { + Logging::Log().SetLevel(Logging::Level::Info); + } + context.UpdateForArgs(); + command->ValidateArguments(context.Args); } // Exceptions specific to parsing the arguments of a command diff --git a/src/AppInstallerCLICore/ExecutionArgs.h b/src/AppInstallerCLICore/ExecutionArgs.h @@ -58,6 +58,7 @@ namespace AppInstaller::CLI::Execution RainbowStyle, // Makes progress display as a rainbow Help, // Show command usage Info, // Show general info about WinGet + VerboseLogs, // Increases winget logging level to verbose }; bool Contains(Type arg) const { return (m_parsedArgs.count(arg) != 0); } diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -330,6 +330,9 @@ <data name="ValidateManifestArgumentDescription" xml:space="preserve"> <value>The path to the manifest to be validated</value> </data> + <data name="VerboseLogsArgumentDescription" xml:space="preserve"> + <value>Enables verbose logging for WinGet</value> + </data> <data name="VersionArgumentDescription" xml:space="preserve"> <value>Use the specified version; default is the latest version</value> </data> diff --git a/src/AppInstallerRepositoryCore/SQLiteWrapper.cpp b/src/AppInstallerRepositoryCore/SQLiteWrapper.cpp @@ -108,7 +108,7 @@ namespace AppInstaller::Repository::SQLite void Connection::EnableICU() { - AICLI_LOG(SQL, Info, << "Enabling ICU"); + AICLI_LOG(SQL, Verbose, << "Enabling ICU"); THROW_IF_SQLITE_FAILED(sqlite3IcuInit(m_dbconn.get())); }