From b0fd9e184a3610a656178753ab4dd30d408c03ff Mon Sep 17 00:00:00 2001 From: Galen Elias Date: Sun, 23 Jun 2019 16:34:32 -0700 Subject: [PATCH] Put logging behind a (default off) registry setting --- GoToFile/GoToFileDlg.cpp | 8 +++----- GoToFile/GoToFileDlg.h | 1 - GoToFile/GoToFileSettings.cpp | 6 +++++- GoToFile/GoToFileSettings.h | 10 +++++++++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/GoToFile/GoToFileDlg.cpp b/GoToFile/GoToFileDlg.cpp index ef26afa..d859ae1 100644 --- a/GoToFile/GoToFileDlg.cpp +++ b/GoToFile/GoToFileDlg.cpp @@ -39,7 +39,6 @@ static int CALLBACK BrowseCallback(HWND hwnd,UINT uMsg, LPARAM /*lParam*/, LPARA int CGoToFileDlg::s_lpSortColumns[CGoToFileDlg::s_iMaxColumns] = { 0, 1, 2, 3 }; bool CGoToFileDlg::s_bSortDescending = false; -bool CGoToFileDlg::s_bLogging = true; CGoToFileDlg::CGoToFileDlg(const CComPtr& spDTE) : m_bInitializing(true) @@ -47,7 +46,6 @@ CGoToFileDlg::CGoToFileDlg(const CComPtr& spDTE) , m_iInitialSize(0) , m_spDTE(spDTE) { - InitializeLogFile(); CreateFileList(); } @@ -128,6 +126,9 @@ LRESULT CGoToFileDlg::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL m_settings.Read(); m_settings.Restore(); + if (m_settings.IsLoggingEnabled()) + InitializeLogFile(); + if (GetSelectedProject() == static_cast(KNOWN_FILTER_BROWSE)) { Stopwatch stopwatch; @@ -1305,9 +1306,6 @@ void CGoToFileDlg::InitializeLogFile() static CHAR s_szLogFilePath[MAX_PATH]; static bool s_initializedLogFilePath = false; - if (!s_bLogging) - return; - if (!s_initializedLogFilePath) { WCHAR wzLogFilePath[MAX_PATH]; diff --git a/GoToFile/GoToFileDlg.h b/GoToFile/GoToFileDlg.h index d46875f..1bb9d26 100644 --- a/GoToFile/GoToFileDlg.h +++ b/GoToFile/GoToFileDlg.h @@ -37,7 +37,6 @@ class CGoToFileDlg : public CAxDialogImpl static constexpr int s_iMaxColumns = 4; static int s_lpSortColumns[s_iMaxColumns]; static bool s_bSortDescending; - static bool s_bLogging; BEGIN_MSG_MAP(CGoToFileDlg) MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) diff --git a/GoToFile/GoToFileSettings.cpp b/GoToFile/GoToFileSettings.cpp index 3d70a50..dd4ed94 100644 --- a/GoToFile/GoToFileSettings.cpp +++ b/GoToFile/GoToFileSettings.cpp @@ -246,7 +246,10 @@ bool GoToFileSettings::ReadFromKey(LPCWSTR pwzRegKey) uiSize = sizeof(m_eViewKind); RegQueryValueEx(hRegHive, L"ViewKind", NULL, NULL, reinterpret_cast(&m_eViewKind), &uiSize); - + + uiSize = sizeof(m_bLogging); + RegQueryValueEx(hRegHive, L"LoggingEnabled", NULL, NULL, reinterpret_cast(&m_bLogging), &uiSize); + return true; } @@ -271,6 +274,7 @@ void GoToFileSettings::Write() RegSetValueEx(hRegHive, L"BrowsePath", 0, REG_SZ, reinterpret_cast(m_browsePath.c_str()), !m_browsePath.empty() ? sizeof(WCHAR) * static_cast(m_browsePath.size() + 1) : 0); RegSetValueEx(hRegHive, L"ViewKind", 0, REG_DWORD, reinterpret_cast(&m_eViewKind), sizeof(m_eViewKind)); + RegSetValueEx(hRegHive, L"LoggingEnabled", 0, REG_DWORD, reinterpret_cast(&m_bLogging), sizeof(m_bLogging)); } } } \ No newline at end of file diff --git a/GoToFile/GoToFileSettings.h b/GoToFile/GoToFileSettings.h index 639b4ad..d0050b4 100644 --- a/GoToFile/GoToFileSettings.h +++ b/GoToFile/GoToFileSettings.h @@ -67,14 +67,20 @@ class GoToFileSettings m_browsePath = lpBrowsePath; } + bool IsLoggingEnabled() const + { + return !!m_bLogging; + } + void Store(); void Restore(); void Read(); void Write(); - bool ReadFromKey(LPCWSTR pwzRegKey); private: + bool ReadFromKey(LPCWSTR pwzRegKey); + bool m_bRestoring; POINT m_location; @@ -85,6 +91,8 @@ class GoToFileSettings long m_iProjectNameWidth; long m_iProjectPathWidth; + DWORD m_bLogging = false; + std::wstring m_project; std::wstring m_filter; std::wstring m_browsePath;