Migrate TraceLogger to runtime class (#772)

This commit is contained in:
Rudy Huyn 2019-11-05 18:59:24 -08:00 committed by Matt Cooley
parent 8ba7234550
commit 577aafb3f4
15 changed files with 97 additions and 100 deletions

View File

@ -85,7 +85,7 @@ void ApplicationViewModel::Initialize(ViewMode mode)
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
TraceLogger::GetInstance().LogStandardException(mode, __FUNCTIONW__, e); TraceLogger::GetInstance()->LogStandardException(mode, __FUNCTIONW__, e);
if (!TryRecoverFromNavigationModeFailure()) if (!TryRecoverFromNavigationModeFailure())
{ {
// Could not navigate to standard mode either. // Could not navigate to standard mode either.
@ -95,7 +95,7 @@ void ApplicationViewModel::Initialize(ViewMode mode)
} }
catch (Exception ^ e) catch (Exception ^ e)
{ {
TraceLogger::GetInstance().LogPlatformException(mode, __FUNCTIONW__, e); TraceLogger::GetInstance()->LogPlatformException(mode, __FUNCTIONW__, e);
if (!TryRecoverFromNavigationModeFailure()) if (!TryRecoverFromNavigationModeFailure())
{ {
// Could not navigate to standard mode either. // Could not navigate to standard mode either.
@ -162,11 +162,11 @@ void ApplicationViewModel::OnModeChanged()
// Log ModeChange event when not first launch, log WindowCreated on first launch // Log ModeChange event when not first launch, log WindowCreated on first launch
if (NavCategory::IsValidViewMode(m_PreviousMode)) if (NavCategory::IsValidViewMode(m_PreviousMode))
{ {
TraceLogger::GetInstance().LogModeChange(m_mode); TraceLogger::GetInstance()->LogModeChange(m_mode);
} }
else else
{ {
TraceLogger::GetInstance().LogWindowCreated(m_mode, ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())); TraceLogger::GetInstance()->LogWindowCreated(m_mode, ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()));
} }
RaisePropertyChanged(ClearMemoryVisibilityPropertyName); RaisePropertyChanged(ClearMemoryVisibilityPropertyName);

View File

@ -108,7 +108,7 @@ String
if (pastedText->Length() > MaxPasteableLength) if (pastedText->Length() > MaxPasteableLength)
{ {
// return NoOp to indicate don't paste anything. // return NoOp to indicate don't paste anything.
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ValidatePasteExpression", L"PastedExpressionSizeGreaterThanMaxAllowed"); TraceLogger::GetInstance()->LogError(mode, L"CopyPasteManager::ValidatePasteExpression", L"PastedExpressionSizeGreaterThanMaxAllowed");
return PasteErrorString; return PasteErrorString;
} }
@ -141,7 +141,7 @@ String
// validate each operand with patterns for different modes // validate each operand with patterns for different modes
if (!ExpressionRegExMatch(operands, mode, modeType, programmerNumberBase, bitLengthType)) if (!ExpressionRegExMatch(operands, mode, modeType, programmerNumberBase, bitLengthType))
{ {
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ValidatePasteExpression", L"InvalidExpressionForPresentMode"); TraceLogger::GetInstance()->LogError(mode, L"CopyPasteManager::ValidatePasteExpression", L"InvalidExpressionForPresentMode");
return PasteErrorString; return PasteErrorString;
} }
@ -187,7 +187,7 @@ vector<wstring> CopyPasteManager::ExtractOperands(const wstring& pasteExpression
if (operands.size() >= MaxOperandCount) if (operands.size() >= MaxOperandCount)
{ {
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ExtractOperands", L"OperandCountGreaterThanMaxCount"); TraceLogger::GetInstance()->LogError(mode, L"CopyPasteManager::ExtractOperands", L"OperandCountGreaterThanMaxCount");
operands.clear(); operands.clear();
return operands; return operands;
} }
@ -201,7 +201,7 @@ vector<wstring> CopyPasteManager::ExtractOperands(const wstring& pasteExpression
// to disallow pasting of 1e+12345 as 1e+1234, max exponent that can be pasted is 9999. // to disallow pasting of 1e+12345 as 1e+1234, max exponent that can be pasted is 9999.
if (expLength > MaxExponentLength) if (expLength > MaxExponentLength)
{ {
TraceLogger::GetInstance().LogError(mode, L"CopyPasteManager::ExtractOperands", L"ExponentLengthGreaterThanMaxLength"); TraceLogger::GetInstance()->LogError(mode, L"CopyPasteManager::ExtractOperands", L"ExponentLengthGreaterThanMaxLength");
operands.clear(); operands.clear();
return operands; return operands;
} }

View File

@ -10,6 +10,7 @@ using namespace CalculatorApp;
using namespace CalculatorApp::Common; using namespace CalculatorApp::Common;
using namespace Concurrency; using namespace Concurrency;
using namespace std; using namespace std;
using namespace Platform;
using namespace winrt; using namespace winrt;
using namespace winrt::Windows::Foundation; using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Diagnostics; using namespace winrt::Windows::Foundation::Diagnostics;
@ -66,38 +67,34 @@ namespace CalculatorApp
CoCreateGuid(&sessionGuid); CoCreateGuid(&sessionGuid);
} }
TraceLogger::~TraceLogger() TraceLogger ^ TraceLogger::GetInstance()
{ {
} static TraceLogger ^ s_selfInstance = ref new TraceLogger();
TraceLogger& TraceLogger::GetInstance()
{
static TraceLogger s_selfInstance;
return s_selfInstance; return s_selfInstance;
} }
bool TraceLogger::GetTraceLoggingProviderEnabled() const bool TraceLogger::GetTraceLoggingProviderEnabled()
{ {
return g_calculatorProvider.Enabled(); return g_calculatorProvider.Enabled();
} }
#pragma region Tracing methods #pragma region Tracing methods
void TraceLogger::LogLevel1Event(wstring_view eventName, LoggingFields fields) const void TraceLogger::LogLevel1Event(wstring_view eventName, LoggingFields fields)
{ {
g_calculatorProvider.LogEvent(eventName, fields, LoggingLevel::Verbose, LoggingOptions(MICROSOFT_KEYWORD_LEVEL_1)); g_calculatorProvider.LogEvent(eventName, fields, LoggingLevel::Verbose, LoggingOptions(MICROSOFT_KEYWORD_LEVEL_1));
} }
void TraceLogger::LogLevel2Event(wstring_view eventName, LoggingFields fields) const void TraceLogger::LogLevel2Event(wstring_view eventName, LoggingFields fields)
{ {
g_calculatorProvider.LogEvent(eventName, fields, LoggingLevel::Verbose, LoggingOptions(MICROSOFT_KEYWORD_LEVEL_2)); g_calculatorProvider.LogEvent(eventName, fields, LoggingLevel::Verbose, LoggingOptions(MICROSOFT_KEYWORD_LEVEL_2));
} }
void TraceLogger::LogLevel3Event(wstring_view eventName, LoggingFields fields) const void TraceLogger::LogLevel3Event(wstring_view eventName, LoggingFields fields)
{ {
g_calculatorProvider.LogEvent(eventName, fields, LoggingLevel::Verbose, LoggingOptions(MICROSOFT_KEYWORD_LEVEL_3)); g_calculatorProvider.LogEvent(eventName, fields, LoggingLevel::Verbose, LoggingOptions(MICROSOFT_KEYWORD_LEVEL_3));
} }
unique_ptr<TraceActivity> TraceLogger::CreateTraceActivity(wstring_view eventName, LoggingFields fields) const unique_ptr<TraceActivity> TraceLogger::CreateTraceActivity(wstring_view eventName, LoggingFields fields)
{ {
return make_unique<TraceActivity>(g_calculatorProvider, eventName, fields); return make_unique<TraceActivity>(g_calculatorProvider, eventName, fields);
} }
@ -117,7 +114,7 @@ namespace CalculatorApp
return true; return true;
} }
void TraceLogger::LogVisualStateChanged(ViewMode mode, wstring_view state, bool isAlwaysOnTop) const void TraceLogger::LogVisualStateChanged(ViewMode mode, String ^ state, bool isAlwaysOnTop)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
{ {
@ -127,7 +124,7 @@ namespace CalculatorApp
LoggingFields fields{}; LoggingFields fields{};
fields.AddGuid(L"SessionGuid", sessionGuid); fields.AddGuid(L"SessionGuid", sessionGuid);
fields.AddString(L"CalcMode", NavCategory::GetFriendlyName(mode)->Data()); fields.AddString(L"CalcMode", NavCategory::GetFriendlyName(mode)->Data());
fields.AddString(L"VisualState", state); fields.AddString(L"VisualState", state->Data());
fields.AddBoolean(L"IsAlwaysOnTop", isAlwaysOnTop); fields.AddBoolean(L"IsAlwaysOnTop", isAlwaysOnTop);
fields.AddUInt64(PDT_PRIVACY_DATA_TAG, PDT_PRODUCT_AND_SERVICE_USAGE); fields.AddUInt64(PDT_PRIVACY_DATA_TAG, PDT_PRODUCT_AND_SERVICE_USAGE);
LogLevel2Event(EVENT_NAME_VISUAL_STATE_CHANGED, fields); LogLevel2Event(EVENT_NAME_VISUAL_STATE_CHANGED, fields);
@ -152,7 +149,7 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_WINDOW_ON_CREATED, fields); LogLevel2Event(EVENT_NAME_WINDOW_ON_CREATED, fields);
} }
void TraceLogger::LogModeChange(ViewMode mode) const void TraceLogger::LogModeChange(ViewMode mode)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;
@ -167,7 +164,7 @@ namespace CalculatorApp
} }
} }
void TraceLogger::LogHistoryItemLoad(ViewMode mode, int historyListSize, int loadedIndex) const void TraceLogger::LogHistoryItemLoad(ViewMode mode, int historyListSize, int loadedIndex)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
{ {
@ -183,7 +180,7 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_HISTORY_ITEM_LOAD, fields); LogLevel2Event(EVENT_NAME_HISTORY_ITEM_LOAD, fields);
} }
void TraceLogger::LogMemoryItemLoad(ViewMode mode, int memoryListSize, int loadedIndex) const void TraceLogger::LogMemoryItemLoad(ViewMode mode, int memoryListSize, int loadedIndex)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
{ {
@ -199,7 +196,7 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_MEMORY_ITEM_LOAD, fields); LogLevel2Event(EVENT_NAME_MEMORY_ITEM_LOAD, fields);
} }
void TraceLogger::LogError(ViewMode mode, wstring_view functionName, wstring_view errorString) void TraceLogger::LogError(ViewMode mode, Platform::String ^ functionName, Platform::String ^ errorString)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;
@ -207,13 +204,13 @@ namespace CalculatorApp
LoggingFields fields{}; LoggingFields fields{};
fields.AddGuid(L"SessionGuid", sessionGuid); fields.AddGuid(L"SessionGuid", sessionGuid);
fields.AddString(L"CalcMode", NavCategory::GetFriendlyName(mode)->Data()); fields.AddString(L"CalcMode", NavCategory::GetFriendlyName(mode)->Data());
fields.AddString(L"FunctionName", functionName); fields.AddString(L"FunctionName", functionName->Data());
fields.AddString(L"Message", errorString); fields.AddString(L"Message", errorString->Data());
fields.AddUInt64(PDT_PRIVACY_DATA_TAG, PDT_PRODUCT_AND_SERVICE_USAGE); fields.AddUInt64(PDT_PRIVACY_DATA_TAG, PDT_PRODUCT_AND_SERVICE_USAGE);
LogLevel2Event(EVENT_NAME_EXCEPTION, fields); LogLevel2Event(EVENT_NAME_EXCEPTION, fields);
} }
void TraceLogger::LogStandardException(ViewMode mode, wstring_view functionName, const exception& e) const void TraceLogger::LogStandardException(ViewMode mode, wstring_view functionName, const exception& e)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;
@ -229,7 +226,7 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_EXCEPTION, fields); LogLevel2Event(EVENT_NAME_EXCEPTION, fields);
} }
void TraceLogger::LogWinRTException(ViewMode mode, wstring_view functionName, hresult_error const& e) const void TraceLogger::LogWinRTException(ViewMode mode, wstring_view functionName, hresult_error const& e)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;
@ -244,7 +241,7 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_EXCEPTION, fields); LogLevel2Event(EVENT_NAME_EXCEPTION, fields);
} }
void TraceLogger::LogPlatformException(ViewMode mode, wstring_view functionName, Platform::Exception ^ e) const void TraceLogger::LogPlatformException(ViewMode mode, wstring_view functionName, Platform::Exception ^ e)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;
@ -291,7 +288,7 @@ namespace CalculatorApp
} }
} }
void TraceLogger::UpdateWindowCount(size_t windowCount) void TraceLogger::UpdateWindowCount(uint64 windowCount)
{ {
if (windowCount == 0) if (windowCount == 0)
{ {
@ -301,6 +298,11 @@ namespace CalculatorApp
currentWindowCount = windowCount; currentWindowCount = windowCount;
} }
void TraceLogger::DecreaseWindowCount()
{
currentWindowCount = 0;
}
void TraceLogger::LogButtonUsage() void TraceLogger::LogButtonUsage()
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
@ -348,7 +350,7 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_DATE_CALCULATION_MODE_USED, fields); LogLevel2Event(EVENT_NAME_DATE_CALCULATION_MODE_USED, fields);
} }
void TraceLogger::LogConverterInputReceived(ViewMode mode) const void TraceLogger::LogConverterInputReceived(ViewMode mode)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;
@ -360,7 +362,7 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_CONVERTER_INPUT_RECEIVED, fields); LogLevel2Event(EVENT_NAME_CONVERTER_INPUT_RECEIVED, fields);
} }
void TraceLogger::LogNavBarOpened() const void TraceLogger::LogNavBarOpened()
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;
@ -371,7 +373,7 @@ namespace CalculatorApp
LogLevel2Event(EVENT_NAME_NAV_BAR_OPENED, fields); LogLevel2Event(EVENT_NAME_NAV_BAR_OPENED, fields);
} }
void TraceLogger::LogInputPasted(ViewMode mode) const void TraceLogger::LogInputPasted(ViewMode mode)
{ {
if (!GetTraceLoggingProviderEnabled()) if (!GetTraceLoggingProviderEnabled())
return; return;

View File

@ -28,33 +28,31 @@ namespace CalculatorApp
} }
}; };
class TraceLogger public
ref class TraceLogger sealed
{ {
public: public:
TraceLogger(_In_ TraceLogger const&) = delete; static TraceLogger ^ GetInstance();
TraceLogger const& operator=(_In_ TraceLogger const&) = delete; bool GetTraceLoggingProviderEnabled();
~TraceLogger(); void LogModeChange(CalculatorApp::Common::ViewMode mode);
static TraceLogger& GetInstance(); void LogHistoryItemLoad(CalculatorApp::Common::ViewMode mode, int historyListSize, int loadedIndex);
bool GetTraceLoggingProviderEnabled() const; void LogMemoryItemLoad(CalculatorApp::Common::ViewMode mode, int memoryListSize, int loadedIndex);
void LogModeChange(CalculatorApp::Common::ViewMode mode) const;
void LogHistoryItemLoad(CalculatorApp::Common::ViewMode mode, int historyListSize, int loadedIndex) const;
void LogMemoryItemLoad(CalculatorApp::Common::ViewMode mode, int memoryListSize, int loadedIndex) const;
void UpdateButtonUsage(CalculatorApp::NumbersAndOperatorsEnum button, CalculatorApp::Common::ViewMode mode); void UpdateButtonUsage(CalculatorApp::NumbersAndOperatorsEnum button, CalculatorApp::Common::ViewMode mode);
void LogButtonUsage(); void LogButtonUsage();
void LogDateCalculationModeUsed(bool AddSubtractMode); void LogDateCalculationModeUsed(bool AddSubtractMode);
void UpdateWindowCount(size_t windowCount = 0); void UpdateWindowCount(uint64 windowCount);
void DecreaseWindowCount();
bool IsWindowIdInLog(int windowId); bool IsWindowIdInLog(int windowId);
void LogVisualStateChanged(CalculatorApp::Common::ViewMode mode, std::wstring_view state, bool isAlwaysOnTop = false) const; void LogVisualStateChanged(CalculatorApp::Common::ViewMode mode, Platform::String ^ state, bool isAlwaysOnTop);
void LogWindowCreated(CalculatorApp::Common::ViewMode mode, int windowId); void LogWindowCreated(CalculatorApp::Common::ViewMode mode, int windowId);
void LogConverterInputReceived(CalculatorApp::Common::ViewMode mode) const; void LogConverterInputReceived(CalculatorApp::Common::ViewMode mode);
void LogNavBarOpened() const; void LogNavBarOpened();
void LogError(CalculatorApp::Common::ViewMode mode, Platform::String ^ functionName, Platform::String ^ errorString);
void LogError(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, std::wstring_view errorString); internal :
void LogStandardException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ const std::exception& e) const; void LogStandardException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ const std::exception& e);
void LogWinRTException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ winrt::hresult_error const& e) const; void LogWinRTException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ winrt::hresult_error const& e);
void LogPlatformException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ Platform::Exception ^ e) const; void LogPlatformException(CalculatorApp::Common::ViewMode mode, std::wstring_view functionName, _In_ Platform::Exception ^ e);
void LogInputPasted(CalculatorApp::Common::ViewMode mode) const; void LogInputPasted(CalculatorApp::Common::ViewMode mode);
private: private:
// Create an instance of TraceLogger // Create an instance of TraceLogger
@ -64,11 +62,11 @@ namespace CalculatorApp
// sampling is involved in Microsoft's diagnostic data collection process. // sampling is involved in Microsoft's diagnostic data collection process.
// These keywords provide additional input into how frequently an event might be sampled. // These keywords provide additional input into how frequently an event might be sampled.
// The lower the level of the keyword, the higher the possibility that the corresponding event may be sampled. // The lower the level of the keyword, the higher the possibility that the corresponding event may be sampled.
void LogLevel1Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const; void LogLevel1Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields);
void LogLevel2Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const; void LogLevel2Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields);
void LogLevel3Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const; void LogLevel3Event(std::wstring_view eventName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields);
std::unique_ptr<TraceActivity> CreateTraceActivity(std::wstring_view activityName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields) const; std::unique_ptr<TraceActivity> CreateTraceActivity(std::wstring_view activityName, winrt::Windows::Foundation::Diagnostics::LoggingFields fields);
winrt::Windows::Foundation::Diagnostics::LoggingChannel g_calculatorProvider; winrt::Windows::Foundation::Diagnostics::LoggingChannel g_calculatorProvider;
@ -76,7 +74,7 @@ namespace CalculatorApp
std::vector<int> windowIdLog; std::vector<int> windowIdLog;
GUID sessionGuid; GUID sessionGuid;
size_t currentWindowCount = 0; uint64 currentWindowCount = 0;
winrt::Windows::Foundation::Diagnostics::LoggingActivity m_appLaunchActivity; winrt::Windows::Foundation::Diagnostics::LoggingActivity m_appLaunchActivity;
}; };

View File

@ -351,12 +351,12 @@ future<bool> CurrencyDataLoader::TryLoadDataFromCacheAsync()
} }
catch (Exception ^ ex) catch (Exception ^ ex)
{ {
TraceLogger::GetInstance().LogPlatformException(ViewMode::Currency, __FUNCTIONW__, ex); TraceLogger::GetInstance()->LogPlatformException(ViewMode::Currency, __FUNCTIONW__, ex);
co_return false; co_return false;
} }
catch (const exception& e) catch (const exception& e)
{ {
TraceLogger::GetInstance().LogStandardException(ViewMode::Currency, __FUNCTIONW__, e); TraceLogger::GetInstance()->LogStandardException(ViewMode::Currency, __FUNCTIONW__, e);
co_return false; co_return false;
} }
catch (...) catch (...)
@ -461,12 +461,12 @@ future<bool> CurrencyDataLoader::TryLoadDataFromWebAsync()
} }
catch (Exception ^ ex) catch (Exception ^ ex)
{ {
TraceLogger::GetInstance().LogPlatformException(ViewMode::Currency, __FUNCTIONW__, ex); TraceLogger::GetInstance()->LogPlatformException(ViewMode::Currency, __FUNCTIONW__, ex);
co_return false; co_return false;
} }
catch (const exception& e) catch (const exception& e)
{ {
TraceLogger::GetInstance().LogStandardException(ViewMode::Currency, __FUNCTIONW__, e); TraceLogger::GetInstance()->LogStandardException(ViewMode::Currency, __FUNCTIONW__, e);
co_return false; co_return false;
} }
catch (...) catch (...)
@ -482,7 +482,7 @@ future<bool> CurrencyDataLoader::TryLoadDataFromWebOverrideAsync()
if (!didLoad) if (!didLoad)
{ {
m_loadStatus = CurrencyLoadStatus::FailedToLoad; m_loadStatus = CurrencyLoadStatus::FailedToLoad;
TraceLogger::GetInstance().LogError(ViewMode::Currency, L"CurrencyDataLoader::TryLoadDataFromWebOverrideAsync", L"UserRequestedRefreshFailed"); TraceLogger::GetInstance()->LogError(ViewMode::Currency, L"CurrencyDataLoader::TryLoadDataFromWebOverrideAsync", L"UserRequestedRefreshFailed");
} }
co_return didLoad; co_return didLoad;

View File

@ -120,7 +120,7 @@ void HistoryViewModel::ShowItem(_In_ HistoryItemViewModel ^ e)
{ {
unsigned int index; unsigned int index;
Items->IndexOf(e, &index); Items->IndexOf(e, &index);
TraceLogger::GetInstance().LogHistoryItemLoad((ViewMode)m_currentMode, ItemSize, (int)(index)); TraceLogger::GetInstance()->LogHistoryItemLoad((ViewMode)m_currentMode, ItemSize, (int)(index));
HistoryItemClicked(e); HistoryItemClicked(e);
} }

View File

@ -674,7 +674,7 @@ void StandardCalculatorViewModel::OnButtonPressed(Object ^ parameter)
m_isLastOperationHistoryLoad = false; m_isLastOperationHistoryLoad = false;
} }
TraceLogger::GetInstance().UpdateButtonUsage(numOpEnum, GetCalculatorMode()); TraceLogger::GetInstance()->UpdateButtonUsage(numOpEnum, GetCalculatorMode());
m_standardCalculatorManager.SendCommand(cmdenum); m_standardCalculatorManager.SendCommand(cmdenum);
} }
} }
@ -753,7 +753,7 @@ void StandardCalculatorViewModel::OnPaste(String ^ pastedString)
return; return;
} }
TraceLogger::GetInstance().LogInputPasted(GetCalculatorMode()); TraceLogger::GetInstance()->LogInputPasted(GetCalculatorMode());
bool isFirstLegalChar = true; bool isFirstLegalChar = true;
m_standardCalculatorManager.SendCommand(Command::CommandCENTR); m_standardCalculatorManager.SendCommand(Command::CommandCENTR);
bool sendNegate = false; bool sendNegate = false;
@ -899,7 +899,7 @@ void StandardCalculatorViewModel::OnClearMemoryCommand(Object ^ parameter)
{ {
m_standardCalculatorManager.MemorizedNumberClearAll(); m_standardCalculatorManager.MemorizedNumberClearAll();
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::MemoryClear, GetCalculatorMode()); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::MemoryClear, GetCalculatorMode());
if (m_localizedMemoryCleared == nullptr) if (m_localizedMemoryCleared == nullptr)
{ {
@ -1055,7 +1055,7 @@ void StandardCalculatorViewModel::OnMemoryButtonPressed()
{ {
m_standardCalculatorManager.MemorizeNumber(); m_standardCalculatorManager.MemorizeNumber();
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::Memory, GetCalculatorMode()); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::Memory, GetCalculatorMode());
if (m_localizedMemorySavedAutomationFormat == nullptr) if (m_localizedMemorySavedAutomationFormat == nullptr)
{ {
@ -1094,7 +1094,7 @@ void StandardCalculatorViewModel::OnMemoryItemPressed(Object ^ memoryItemPositio
HideMemoryClicked(); HideMemoryClicked();
auto mode = IsStandard ? ViewMode::Standard : IsScientific ? ViewMode::Scientific : ViewMode::Programmer; auto mode = IsStandard ? ViewMode::Standard : IsScientific ? ViewMode::Scientific : ViewMode::Programmer;
TraceLogger::GetInstance().LogMemoryItemLoad(mode, MemorizedNumbers->Size, boxedPosition->Value); TraceLogger::GetInstance()->LogMemoryItemLoad(mode, MemorizedNumbers->Size, boxedPosition->Value);
} }
} }
@ -1105,7 +1105,7 @@ void StandardCalculatorViewModel::OnMemoryAdd(Object ^ memoryItemPosition)
if (MemorizedNumbers) if (MemorizedNumbers)
{ {
auto boxedPosition = safe_cast<Box<int> ^>(memoryItemPosition); auto boxedPosition = safe_cast<Box<int> ^>(memoryItemPosition);
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::MemoryAdd, GetCalculatorMode()); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::MemoryAdd, GetCalculatorMode());
m_standardCalculatorManager.MemorizedNumberAdd(boxedPosition->Value); m_standardCalculatorManager.MemorizedNumberAdd(boxedPosition->Value);
} }
} }
@ -1116,7 +1116,7 @@ void StandardCalculatorViewModel::OnMemorySubtract(Object ^ memoryItemPosition)
if (MemorizedNumbers) if (MemorizedNumbers)
{ {
auto boxedPosition = safe_cast<Box<int> ^>(memoryItemPosition); auto boxedPosition = safe_cast<Box<int> ^>(memoryItemPosition);
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::MemorySubtract, GetCalculatorMode()); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::MemorySubtract, GetCalculatorMode());
m_standardCalculatorManager.MemorizedNumberSubtract(boxedPosition->Value); m_standardCalculatorManager.MemorizedNumberSubtract(boxedPosition->Value);
} }
} }
@ -1142,7 +1142,7 @@ void StandardCalculatorViewModel::OnMemoryClear(_In_ Object ^ memoryItemPosition
{ {
IsMemoryEmpty = true; IsMemoryEmpty = true;
} }
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::MemoryClear, GetCalculatorMode()); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::MemoryClear, GetCalculatorMode());
wstring localizedIndex = to_wstring(boxedPosition->Value + 1); wstring localizedIndex = to_wstring(boxedPosition->Value + 1);
LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedIndex); LocalizationSettings::GetInstance().LocalizeDisplayValue(&localizedIndex);
@ -1189,7 +1189,7 @@ void StandardCalculatorViewModel::OnPropertyChanged(String ^ propertyname)
} }
else if (propertyname == IsBitFlipCheckedPropertyName) else if (propertyname == IsBitFlipCheckedPropertyName)
{ {
TraceLogger::GetInstance().UpdateButtonUsage( TraceLogger::GetInstance()->UpdateButtonUsage(
IsBitFlipChecked ? NumbersAndOperatorsEnum::BitflipButton : NumbersAndOperatorsEnum::FullKeypadButton, ViewMode::Programmer); IsBitFlipChecked ? NumbersAndOperatorsEnum::BitflipButton : NumbersAndOperatorsEnum::FullKeypadButton, ViewMode::Programmer);
} }
} }

View File

@ -494,7 +494,7 @@ void UnitConverterViewModel::OnButtonPressed(Platform::Object ^ parameter)
m_model->SendCommand(command); m_model->SendCommand(command);
TraceLogger::GetInstance().LogConverterInputReceived(Mode); TraceLogger::GetInstance()->LogConverterInputReceived(Mode);
} }
void UnitConverterViewModel::OnCopyCommand(Platform::Object ^ parameter) void UnitConverterViewModel::OnCopyCommand(Platform::Object ^ parameter)
@ -887,7 +887,7 @@ void UnitConverterViewModel::OnPaste(String ^ stringToPaste)
return; return;
} }
TraceLogger::GetInstance().LogInputPasted(Mode); TraceLogger::GetInstance()->LogInputPasted(Mode);
bool isFirstLegalChar = true; bool isFirstLegalChar = true;
bool sendNegate = false; bool sendNegate = false;
wstring accumulation = L""; wstring accumulation = L"";

View File

@ -97,7 +97,7 @@ void App::AddWindowToMap(_In_ WindowFrameService ^ frameService)
{ {
reader_writer_lock::scoped_lock lock(m_windowsMapLock); reader_writer_lock::scoped_lock lock(m_windowsMapLock);
m_secondaryWindows[frameService->GetViewId()] = frameService; m_secondaryWindows[frameService->GetViewId()] = frameService;
TraceLogger::GetInstance().UpdateWindowCount(m_secondaryWindows.size()); TraceLogger::GetInstance()->UpdateWindowCount(m_secondaryWindows.size());
} }
WindowFrameService ^ App::GetWindowFromMap(int viewId) WindowFrameService ^ App::GetWindowFromMap(int viewId)
@ -363,7 +363,7 @@ void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
} }
else else
{ {
TraceLogger::GetInstance().LogError(ViewMode::None, L"App::OnAppLaunch", L"Null_ActivationViewSwitcher"); TraceLogger::GetInstance()->LogError(ViewMode::None, L"App::OnAppLaunch", L"Null_ActivationViewSwitcher");
} }
} }
// Set the preLaunched flag to false // Set the preLaunched flag to false
@ -439,7 +439,7 @@ void App::OnActivated(IActivatedEventArgs ^ args)
void CalculatorApp::App::OnSuspending(Object ^ sender, SuspendingEventArgs ^ args) void CalculatorApp::App::OnSuspending(Object ^ sender, SuspendingEventArgs ^ args)
{ {
TraceLogger::GetInstance().LogButtonUsage(); TraceLogger::GetInstance()->LogButtonUsage();
} }
void App::DismissedEventHandler(SplashScreen ^ sender, Object ^ e) void App::DismissedEventHandler(SplashScreen ^ sender, Object ^ e)

View File

@ -137,7 +137,7 @@ void Calculator::OnLoaded(_In_ Object ^, _In_ RoutedEventArgs ^)
WeakReference weakThis(this); WeakReference weakThis(this);
this->Dispatcher->RunAsync( this->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal, ref new DispatchedHandler([weakThis]() { CoreDispatcherPriority::Normal, ref new DispatchedHandler([weakThis]() {
if (TraceLogger::GetInstance().IsWindowIdInLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()))) if (TraceLogger::GetInstance()->IsWindowIdInLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
{ {
auto refThis = weakThis.Resolve<Calculator>(); auto refThis = weakThis.Resolve<Calculator>();
if (refThis != nullptr) if (refThis != nullptr)
@ -707,8 +707,7 @@ void Calculator::OnMemoryAccessKeyInvoked(_In_ UIElement ^ sender, _In_ AccessKe
void CalculatorApp::Calculator::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e) void CalculatorApp::Calculator::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e)
{ {
auto mode = IsStandard ? ViewMode::Standard : IsScientific ? ViewMode::Scientific : ViewMode::Programmer; auto mode = IsStandard ? ViewMode::Standard : IsScientific ? ViewMode::Scientific : ViewMode::Programmer;
auto state = std::wstring(e->NewState->Name->Begin()); TraceLogger::GetInstance()->LogVisualStateChanged(mode, e->NewState->Name, IsAlwaysOnTop);
TraceLogger::GetInstance().LogVisualStateChanged(mode, state, IsAlwaysOnTop);
} }
void Calculator::Calculator_SizeChanged(Object ^ /*sender*/, SizeChangedEventArgs ^ /*e*/) void Calculator::Calculator_SizeChanged(Object ^ /*sender*/, SizeChangedEventArgs ^ /*e*/)

View File

@ -38,7 +38,7 @@ CalculatorProgrammerOperators::CalculatorProgrammerOperators()
void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e) void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
{ {
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::HexButton, ViewMode::Programmer); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::HexButton, ViewMode::Programmer);
if (Model) if (Model)
{ {
Model->SwitchProgrammerModeBase(RADIX_TYPE::HEX_RADIX); Model->SwitchProgrammerModeBase(RADIX_TYPE::HEX_RADIX);
@ -47,7 +47,7 @@ void CalculatorProgrammerOperators::HexButtonChecked(_In_ Object ^ sender, _In_
void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e) void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
{ {
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::DecButton, ViewMode::Programmer); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::DecButton, ViewMode::Programmer);
if (Model) if (Model)
{ {
Model->SwitchProgrammerModeBase(RADIX_TYPE::DEC_RADIX); Model->SwitchProgrammerModeBase(RADIX_TYPE::DEC_RADIX);
@ -56,7 +56,7 @@ void CalculatorProgrammerOperators::DecButtonChecked(_In_ Object ^ sender, _In_
void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e) void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
{ {
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::OctButton, ViewMode::Programmer); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::OctButton, ViewMode::Programmer);
if (Model) if (Model)
{ {
Model->SwitchProgrammerModeBase(RADIX_TYPE::OCT_RADIX); Model->SwitchProgrammerModeBase(RADIX_TYPE::OCT_RADIX);
@ -65,7 +65,7 @@ void CalculatorProgrammerOperators::OctButtonChecked(_In_ Object ^ sender, _In_
void CalculatorProgrammerOperators::BinButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e) void CalculatorProgrammerOperators::BinButtonChecked(_In_ Object ^ sender, _In_ RoutedEventArgs ^ e)
{ {
TraceLogger::GetInstance().UpdateButtonUsage(NumbersAndOperatorsEnum::BinButton, ViewMode::Programmer); TraceLogger::GetInstance()->UpdateButtonUsage(NumbersAndOperatorsEnum::BinButton, ViewMode::Programmer);
if (Model) if (Model)
{ {
Model->SwitchProgrammerModeBase(RADIX_TYPE::BIN_RADIX); Model->SwitchProgrammerModeBase(RADIX_TYPE::BIN_RADIX);

View File

@ -103,7 +103,7 @@ void DateCalculator::FromDate_DateChanged(_In_ CalendarDatePicker ^ sender, _In_
{ {
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext); auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
dateCalcViewModel->FromDate = e->NewDate->Value; dateCalcViewModel->FromDate = e->NewDate->Value;
TraceLogger::GetInstance().LogDateCalculationModeUsed(false /* AddSubtractMode */); TraceLogger::GetInstance()->LogDateCalculationModeUsed(false /* AddSubtractMode */);
} }
else else
{ {
@ -117,7 +117,7 @@ void DateCalculator::ToDate_DateChanged(_In_ CalendarDatePicker ^ sender, _In_ C
{ {
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext); auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
dateCalcViewModel->ToDate = e->NewDate->Value; dateCalcViewModel->ToDate = e->NewDate->Value;
TraceLogger::GetInstance().LogDateCalculationModeUsed(false /* AddSubtractMode */); TraceLogger::GetInstance()->LogDateCalculationModeUsed(false /* AddSubtractMode */);
} }
else else
{ {
@ -131,7 +131,7 @@ void DateCalculator::AddSubtract_DateChanged(_In_ CalendarDatePicker ^ sender, _
{ {
auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext); auto dateCalcViewModel = safe_cast<DateCalculatorViewModel ^>(this->DataContext);
dateCalcViewModel->StartDate = e->NewDate->Value; dateCalcViewModel->StartDate = e->NewDate->Value;
TraceLogger::GetInstance().LogDateCalculationModeUsed(true /* AddSubtractMode */); TraceLogger::GetInstance()->LogDateCalculationModeUsed(true /* AddSubtractMode */);
} }
else else
{ {
@ -145,7 +145,7 @@ void CalculatorApp::DateCalculator::OffsetValue_Changed(_In_ Platform::Object ^
// do not log diagnostics for no-ops and initialization of combo boxes // do not log diagnostics for no-ops and initialization of combo boxes
if (dateCalcViewModel->DaysOffset != 0 || dateCalcViewModel->MonthsOffset != 0 || dateCalcViewModel->YearsOffset != 0) if (dateCalcViewModel->DaysOffset != 0 || dateCalcViewModel->MonthsOffset != 0 || dateCalcViewModel->YearsOffset != 0)
{ {
TraceLogger::GetInstance().LogDateCalculationModeUsed(true /* AddSubtractMode */); TraceLogger::GetInstance()->LogDateCalculationModeUsed(true /* AddSubtractMode */);
} }
} }
@ -237,6 +237,5 @@ void DateCalculator::AddSubtractOption_Checked(_In_ Object ^ sender, _In_ Routed
void CalculatorApp::DateCalculator::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e) void CalculatorApp::DateCalculator::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e)
{ {
auto state = std::wstring(e->NewState->Name->Begin()); TraceLogger::GetInstance()->LogVisualStateChanged(ViewMode::Date, e->NewState->Name, false);
TraceLogger::GetInstance().LogVisualStateChanged(ViewMode::Date, state);
} }

View File

@ -256,7 +256,7 @@ void MainPage::OnPageLoaded(_In_ Object ^, _In_ RoutedEventArgs ^ args)
// Delay load things later when we get a chance. // Delay load things later when we get a chance.
this->Dispatcher->RunAsync( this->Dispatcher->RunAsync(
CoreDispatcherPriority::Normal, ref new DispatchedHandler([]() { CoreDispatcherPriority::Normal, ref new DispatchedHandler([]() {
if (TraceLogger::GetInstance().IsWindowIdInLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread()))) if (TraceLogger::GetInstance()->IsWindowIdInLog(ApplicationView::GetApplicationViewIdForWindow(CoreWindow::GetForCurrentThread())))
{ {
AppLifecycleLogger::GetInstance().LaunchUIResponsive(); AppLifecycleLogger::GetInstance().LaunchUIResponsive();
AppLifecycleLogger::GetInstance().LaunchVisibleComplete(); AppLifecycleLogger::GetInstance().LaunchVisibleComplete();
@ -391,7 +391,7 @@ void MainPage::OnNavPaneOpening(_In_ MUXC::NavigationView ^ sender, _In_ Object
void MainPage::OnNavPaneOpened(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args) void MainPage::OnNavPaneOpened(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args)
{ {
KeyboardShortcutManager::HonorShortcuts(false); KeyboardShortcutManager::HonorShortcuts(false);
TraceLogger::GetInstance().LogNavBarOpened(); TraceLogger::GetInstance()->LogNavBarOpened();
} }
void MainPage::OnNavPaneClosed(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args) void MainPage::OnNavPaneClosed(_In_ MUXC::NavigationView ^ sender, _In_ Object ^ args)

View File

@ -377,6 +377,5 @@ void CalculatorApp::UnitConverter::SupplementaryResultsPanelInGrid_SizeChanged(P
void CalculatorApp::UnitConverter::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e) void CalculatorApp::UnitConverter::OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e)
{ {
auto mode = NavCategory::Deserialize(Model->CurrentCategory->GetModelCategory().id); auto mode = NavCategory::Deserialize(Model->CurrentCategory->GetModelCategory().id);
auto state = std::wstring(e->NewState->Name->Begin()); TraceLogger::GetInstance()->LogVisualStateChanged(mode, e->NewState->Name, false);
TraceLogger::GetInstance().LogVisualStateChanged(mode, state);
} }

View File

@ -118,7 +118,7 @@ namespace CalculatorApp
void WindowFrameService::OnConsolidated(_In_ ApplicationView ^ sender, _In_ ApplicationViewConsolidatedEventArgs ^ e) void WindowFrameService::OnConsolidated(_In_ ApplicationView ^ sender, _In_ ApplicationViewConsolidatedEventArgs ^ e)
{ {
TraceLogger::GetInstance().UpdateWindowCount(); TraceLogger::GetInstance()->DecreaseWindowCount();
auto parent = m_parent.Resolve<App>(); auto parent = m_parent.Resolve<App>();
if (parent != nullptr) if (parent != nullptr)
{ {