From ec2f3f7f0a50747ea376ab3d933e3cf870a6424c Mon Sep 17 00:00:00 2001 From: John McPherson Date: Thu, 14 Nov 2024 11:38:43 -0800 Subject: [PATCH] Also use during COM init --- src/AppInstallerCLICore/COMContext.cpp | 8 ++++++++ src/AppInstallerCLICore/Core.cpp | 22 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/AppInstallerCLICore/COMContext.cpp b/src/AppInstallerCLICore/COMContext.cpp index 2eae8694d7..a76bcf2e61 100644 --- a/src/AppInstallerCLICore/COMContext.cpp +++ b/src/AppInstallerCLICore/COMContext.cpp @@ -4,6 +4,7 @@ #include "COMContext.h" #include #include +#include namespace AppInstaller::CLI::Execution { @@ -77,12 +78,19 @@ namespace AppInstaller::CLI::Execution void COMContext::SetLoggers(std::optional channel, std::optional level) { + // Set up debug string logging during initialization + Logging::OutputDebugStringLogger::Add(); + Logging::Log().EnableChannel(Logging::Channel::All); + Logging::Log().SetLevel(Logging::Level::Verbose); + Logging::Log().EnableChannel(channel.has_value() ? channel.value() : Settings::User().Get()); Logging::Log().SetLevel(level.has_value() ? level.value() : Settings::User().Get()); // TODO: Log to file for COM API calls only when debugging in visual studio Logging::FileLogger::Add(s_comLogFileNamePrefix); + Logging::OutputDebugStringLogger::Remove(); + #ifndef AICLI_DISABLE_TEST_HOOKS if (!Settings::User().Get()) #endif diff --git a/src/AppInstallerCLICore/Core.cpp b/src/AppInstallerCLICore/Core.cpp index 1b703e1874..f75193f9ec 100644 --- a/src/AppInstallerCLICore/Core.cpp +++ b/src/AppInstallerCLICore/Core.cpp @@ -185,11 +185,18 @@ namespace AppInstaller::CLI void ServerInitialize() { -#ifndef AICLI_DISABLE_TEST_HOOKS +#ifndef AICLI_DISABLE_TEST_HOOKS + // We have to do this here so the auto minidump config initialization gets caught + Logging::OutputDebugStringLogger::Add(); + Logging::Log().EnableChannel(Logging::Channel::All); + Logging::Log().SetLevel(Logging::Level::Verbose); + if (Settings::User().Get()) { Debugging::EnableSelfInitiatedMinidump(); - } + } + + Logging::OutputDebugStringLogger::Remove(); #endif AppInstaller::CLI::Execution::COMContext::SetLoggers(); @@ -197,11 +204,18 @@ namespace AppInstaller::CLI void InProcInitialize() { -#ifndef AICLI_DISABLE_TEST_HOOKS +#ifndef AICLI_DISABLE_TEST_HOOKS + // We have to do this here so the auto minidump config initialization gets caught + Logging::OutputDebugStringLogger::Add(); + Logging::Log().EnableChannel(Logging::Channel::All); + Logging::Log().SetLevel(Logging::Level::Verbose); + if (Settings::User().Get()) { Debugging::EnableSelfInitiatedMinidump(); - } + } + + Logging::OutputDebugStringLogger::Remove(); #endif // Explicitly set default channel and level before user settings from PackageManagerSettings