From 5137eed7599cb3d0ad5a87a0c9cafc53f792b144 Mon Sep 17 00:00:00 2001 From: W0LF Date: Fri, 10 Dec 2021 03:24:43 +0300 Subject: [PATCH] Added backing up previous logfile --- wCenterWindow/Logger.cpp | 5 +++++ wCenterWindow/wCenterWindow.cpp | 13 +++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wCenterWindow/Logger.cpp b/wCenterWindow/Logger.cpp index f777fe1..314e3f2 100644 --- a/wCenterWindow/Logger.cpp +++ b/wCenterWindow/Logger.cpp @@ -37,6 +37,11 @@ void OpenLogFile() { fs::path log_path = lpszPath; log_path.replace_extension(L".log"); std::wstring logname = log_path.stem() += L".log"; + std::wstring backupname = log_path.stem() += L".bak"; + + if (fs::exists(logname)) { + fs::rename(logname, backupname); + } logfile.open(logname); if (logfile.is_open()) { diff --git a/wCenterWindow/wCenterWindow.cpp b/wCenterWindow/wCenterWindow.cpp index ea9ca9d..6993771 100644 --- a/wCenterWindow/wCenterWindow.cpp +++ b/wCenterWindow/wCenterWindow.cpp @@ -67,7 +67,7 @@ VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize) LONG nWidth = fgwrc.right - fgwrc.left; LONG nHeight = fgwrc.bottom - fgwrc.top; - diag_log(L"Moving window from x =", fgwrc.left, L" y =", fgwrc.top, L" r =", fgwrc.right, L" b =", fgwrc.bottom); + diag_log(L"Moving window from x =", fgwrc.left, L"y =", fgwrc.top); MONITORINFO mi; mi.cbSize = sizeof(MONITORINFO); @@ -101,7 +101,8 @@ VOID MoveWindowToMonitorCenter(HWND hwnd, BOOL bWorkArea, BOOL bResize) MoveWindow(hwnd, x, y, nWidth, nHeight, TRUE); SendMessage(hwnd, WM_EXITSIZEMOVE, NULL, NULL); - diag_log(L"Moving window to x =", x, L" y =", y, L" r =", aw, L" b =", ah); + diag_log(L"Moving window to x =", x, L"y =", y); + diag_log(L"Quiting MoveWindowToMonitorCenter()"); } @@ -112,7 +113,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm UNREFERENCED_PARAMETER(lpCmdLine); OpenLogFile(); - diag_log(L"Entering WinMain()..."); + diag_log(L"Entering WinMain()"); hInst = hInstance; @@ -136,7 +137,7 @@ int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCm int nArgs = 0; LPWSTR* szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs); - diag_log(L"nArgs =", nArgs, L" Args: ", *szArglist); + diag_log(L"nArgs =", nArgs, L", Args: ", *szArglist); (nArgs >= 2 && 0 == lstrcmpiW(szArglist[1], TEXT("/hide"))) ? bShowIcon = FALSE : bShowIcon = TRUE; LocalFree(szArglist); @@ -400,7 +401,7 @@ BOOL CheckWindow(HWND hFW) VOID HandlingTrayIcon() { - diag_log(L"Entering HandlingTrayIcon()...", L" bShowIcon=", bShowIcon); + diag_log(L"Entering HandlingTrayIcon(). bShowIcon =", bShowIcon); if (bShowIcon) { if (!Shell_NotifyIcon(NIM_ADD, &nid)) @@ -414,7 +415,7 @@ VOID HandlingTrayIcon() { Shell_NotifyIcon(NIM_DELETE, &nid); } - diag_log(L"Quiting HandlingTrayIcon()..."); + diag_log(L"Quiting HandlingTrayIcon()"); } VOID ShowError(UINT uID)