Skip to content

Commit

Permalink
Put logging behind a (default off) registry setting
Browse files Browse the repository at this point in the history
  • Loading branch information
galenelias committed Jun 23, 2019
1 parent 1f5f48c commit b0fd9e1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
8 changes: 3 additions & 5 deletions GoToFile/GoToFileDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ 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<VxDTE::_DTE>& spDTE)
: m_bInitializing(true)
, m_settings(*this)
, m_iInitialSize(0)
, m_spDTE(spDTE)
{
InitializeLogFile();
CreateFileList();
}

Expand Down Expand Up @@ -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<unsigned int>(KNOWN_FILTER_BROWSE))
{
Stopwatch stopwatch;
Expand Down Expand Up @@ -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];
Expand Down
1 change: 0 additions & 1 deletion GoToFile/GoToFileDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class CGoToFileDlg : public CAxDialogImpl<CGoToFileDlg>
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)
Expand Down
6 changes: 5 additions & 1 deletion GoToFile/GoToFileSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ bool GoToFileSettings::ReadFromKey(LPCWSTR pwzRegKey)

uiSize = sizeof(m_eViewKind);
RegQueryValueEx(hRegHive, L"ViewKind", NULL, NULL, reinterpret_cast<LPBYTE>(&m_eViewKind), &uiSize);


uiSize = sizeof(m_bLogging);
RegQueryValueEx(hRegHive, L"LoggingEnabled", NULL, NULL, reinterpret_cast<LPBYTE>(&m_bLogging), &uiSize);

return true;
}

Expand All @@ -271,6 +274,7 @@ void GoToFileSettings::Write()
RegSetValueEx(hRegHive, L"BrowsePath", 0, REG_SZ, reinterpret_cast<const BYTE *>(m_browsePath.c_str()), !m_browsePath.empty() ? sizeof(WCHAR) * static_cast<DWORD>(m_browsePath.size() + 1) : 0);

RegSetValueEx(hRegHive, L"ViewKind", 0, REG_DWORD, reinterpret_cast<const LPBYTE>(&m_eViewKind), sizeof(m_eViewKind));
RegSetValueEx(hRegHive, L"LoggingEnabled", 0, REG_DWORD, reinterpret_cast<const LPBYTE>(&m_bLogging), sizeof(m_bLogging));
}
}
}
10 changes: 9 additions & 1 deletion GoToFile/GoToFileSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit b0fd9e1

Please sign in to comment.