From cd7297de6f8cb01f9a48489703e75859c8fc0680 Mon Sep 17 00:00:00 2001 From: fanlumaster <1730976608@qq.com> Date: Sat, 8 Nov 2025 16:37:39 +0800 Subject: [PATCH] [log]: add line break --- server/src/ipc/event_listener.cpp | 48 ++++++++++++------------ server/src/ipc/ipc.cpp | 14 +++---- server/src/utils/webview_utils.cpp | 2 +- server/src/webview2/windows_webview2.cpp | 24 ++++++------ server/src/window/ime_windows.cpp | 4 +- 5 files changed, 46 insertions(+), 46 deletions(-) diff --git a/server/src/ipc/event_listener.cpp b/server/src/ipc/event_listener.cpp index b5d18d36..2c2b218a 100644 --- a/server/src/ipc/event_listener.cpp +++ b/server/src/ipc/event_listener.cpp @@ -57,7 +57,7 @@ void WorkerThread() if (!hEvent) { // TODO: Error handling - OutputDebugString(L"FanyImeTimeToWritePipeEvent OpenEvent failed"); + OutputDebugString(L"FanyImeTimeToWritePipeEvent OpenEvent failed\n"); } while (pipe_running) @@ -132,15 +132,15 @@ void EventListenerLoopThread() if (!hCancelToTsfPipeConnectEvent) { // TODO: Error handling - OutputDebugString(L"FanyImeCancelToWritePipeEvent OpenEvent failed"); + OutputDebugString(L"FanyImeCancelToWritePipeEvent OpenEvent failed\n"); } while (true) { spdlog::info("Pipe starts to wait"); - OutputDebugString(L"Pipe starts to wait"); + OutputDebugString(L"Pipe starts to wait\n"); BOOL connected = ConnectNamedPipe(hPipe, NULL); spdlog::info("Pipe connected: {}", connected); - OutputDebugString(fmt::format(L"Pipe connected: {}", connected).c_str()); + OutputDebugString(fmt::format(L"Pipe connected: {}\n", connected).c_str()); ::mainConnected = connected; if (connected) { @@ -158,19 +158,19 @@ void EventListenerLoopThread() if (!readResult || bytesRead == 0) // Disconnected or error { // TODO: Log - OutputDebugString(L"Pipe disconnected or error"); + OutputDebugString(L"Pipe disconnected or error\n"); // We alse need to disconnect toTsf named pipe if (::toTsfConnected) { - OutputDebugString(L"Really disconnect toTsf pipe"); + OutputDebugString(L"Really disconnect toTsf pipe\n"); // DisconnectNamedPipe toTsf hPipe if (!SetEvent(hCancelToTsfPipeConnectEvent)) { // TODO: Error handling - OutputDebugString(L"hCancelToTsfPipeConnectEvent SetEvent failed"); + OutputDebugString(L"hCancelToTsfPipeConnectEvent SetEvent failed\n"); } - OutputDebugString(L"End disconnect toTsf pipe"); + OutputDebugString(L"End disconnect toTsf pipe\n"); } break; } @@ -209,7 +209,7 @@ void EventListenerLoopThread() { // TODO: } - OutputDebugString(L"Pipe disconnected"); + OutputDebugString(L"Pipe disconnected\n"); DisconnectNamedPipe(hPipe); } @@ -238,11 +238,11 @@ void ToTsfPipeEventListenerLoopThread() while (true) { spdlog::info("ToTsf Pipe starts to wait"); - OutputDebugString(L"ToTsf Pipe starts to wait"); + OutputDebugString(L"ToTsf Pipe starts to wait\n"); BOOL connected = ConnectNamedPipe(hToTsfPipe, NULL); ::toTsfConnected = connected; spdlog::info("ToTsf Pipe connected: {}", connected); - OutputDebugString(fmt::format(L"ToTsf Pipe connected: {}", connected).c_str()); + OutputDebugString(fmt::format(L"ToTsf Pipe connected: {}\n", connected).c_str()); if (connected) { // Wait for event to write data to tsf @@ -266,7 +266,7 @@ void ToTsfPipeEventListenerLoopThread() break; } case 1: { // Cancel event - OutputDebugString(L"Event canceled."); + OutputDebugString(L"Event canceled.\n"); isBreakWhile = true; break; } @@ -282,7 +282,7 @@ void ToTsfPipeEventListenerLoopThread() { // TODO: } - OutputDebugString(L"ToTsf Pipe disconnected"); + OutputDebugString(L"ToTsf Pipe disconnected\n"); DisconnectNamedPipe(hToTsfPipe); } ::CloseToTsfNamedPipe(); @@ -293,10 +293,10 @@ void AuxPipeEventListenerLoopThread() while (true) { spdlog::info("Aux Pipe starts to wait"); - OutputDebugString(L"Aux Pipe starts to wait"); + OutputDebugString(L"Aux Pipe starts to wait\n"); BOOL connected = ConnectNamedPipe(hAuxPipe, NULL); spdlog::info("Aux Pipe connected: {}", connected); - OutputDebugString(fmt::format(L"Aux Pipe connected: {}", connected).c_str()); + OutputDebugString(fmt::format(L"Aux Pipe connected: {}\n", connected).c_str()); if (connected) { wchar_t buffer[128] = {0}; @@ -315,17 +315,17 @@ void AuxPipeEventListenerLoopThread() else { std::wstring message(buffer, bytesRead / sizeof(wchar_t)); - OutputDebugString(message.c_str()); + OutputDebugString((message + L"\n").c_str()); if (message == L"kill") { - OutputDebugString(L" Pipe to disconnect main and toTsf pipe"); + OutputDebugString(L" Pipe to disconnect main and toTsf pipe\n"); if (::mainConnected) { OutputDebugString(L"Really disconnect main pipe"); // DisconnectNamedPipe hPipe CancelSynchronousIo(::mainPipeThread); - OutputDebugString(L"End disconnect main pipe"); + OutputDebugString(L"End disconnect main pipe\n"); } // if (::toTsfConnected) // { @@ -341,7 +341,7 @@ void AuxPipeEventListenerLoopThread() { // TODO: } - OutputDebugString(L"Aux Pipe disconnected"); + OutputDebugString(L"Aux Pipe disconnected\n"); DisconnectNamedPipe(hAuxPipe); } ::CloseAuxNamedPipe(); @@ -429,7 +429,7 @@ void HandleImeKey(HANDLE hEvent) if (!SetEvent(hEvent)) { // TODO: Error handling - OutputDebugString(L"SetEvent failed"); + OutputDebugString(L"SetEvent failed\n"); } } } @@ -449,7 +449,7 @@ void HandleImeKey(HANDLE hEvent) if (!SetEvent(hEvent)) { // TODO: Error handling - OutputDebugString(L"SetEvent failed"); + OutputDebugString(L"SetEvent failed\n"); } } } @@ -478,7 +478,7 @@ void HandleImeKey(HANDLE hEvent) if (!SetEvent(hEvent)) { // TODO: Error handling - OutputDebugString(L"SetEvent failed"); + OutputDebugString(L"SetEvent failed\n"); } /* 清理状态 */ @@ -556,7 +556,7 @@ void HandleImeKey(HANDLE hEvent) if (PinyinUtil::cnt_han_chars(GlobalIme::word_for_creating_word) * 2 == GlobalIme::pinyin_for_creating_word.size()) { /* 最终的造词 */ - OutputDebugString(fmt::format(L"create_word 造词:{} {}", + OutputDebugString(fmt::format(L"create_word 造词:{} {}\n", string_to_wstring(GlobalIme::word_for_creating_word), string_to_wstring(GlobalIme::pinyin_for_creating_word)) .c_str()); @@ -605,7 +605,7 @@ void HandleImeKey(HANDLE hEvent) if (!SetEvent(hEvent)) { /* 触发事件,将候选词数据写入管道 */ // TODO: Error handling - OutputDebugString(L"SetEvent failed"); + OutputDebugString(L"SetEvent failed\n"); } } else if (Global::Keycode == VK_OEM_MINUS || // diff --git a/server/src/ipc/ipc.cpp b/server/src/ipc/ipc.cpp index ef764ca9..4921448a 100644 --- a/server/src/ipc/ipc.cpp +++ b/server/src/ipc/ipc.cpp @@ -225,20 +225,20 @@ int InitNamedPipe() if (hAuxPipe == INVALID_HANDLE_VALUE) { - OutputDebugString(fmt::format(L"CreateNamedPipe aux pipe failed: {}", GetLastError()).c_str()); + OutputDebugString(fmt::format(L"CreateNamedPipe aux pipe failed: {}\n", GetLastError()).c_str()); } else { - OutputDebugString(L"Named pipe aux pipe created successfully"); + OutputDebugString(L"Named pipe aux pipe created successfully\n"); } if (hToTsfPipe == INVALID_HANDLE_VALUE) { - OutputDebugString(fmt::format(L"CreateNamedPipe to tsf pipe failed: {}", GetLastError()).c_str()); + OutputDebugString(fmt::format(L"CreateNamedPipe to tsf pipe failed: {}\n", GetLastError()).c_str()); } else { - OutputDebugString(L"Named pipe to tsf pipe created successfully"); + OutputDebugString(L"Named pipe to tsf pipe created successfully\n"); } // @@ -255,7 +255,7 @@ int InitNamedPipe() if (!hEvent) { // Error handling - OutputDebugString(fmt::format(L"CreateEvent failed: {}", GetLastError()).c_str()); + OutputDebugString(fmt::format(L"CreateEvent failed: {}\n", GetLastError()).c_str()); } } @@ -424,7 +424,7 @@ void SendToTsfViaNamedpipe(UINT msg_type, std::wstring &pipeData) if (!hToTsfPipe || hToTsfPipe == INVALID_HANDLE_VALUE) { // TODO: Error handling - OutputDebugString(L"SendToTsfViaNamedpipe Pipe disconnected"); + OutputDebugString(L"SendToTsfViaNamedpipe Pipe disconnected\n"); return; } DWORD bytesWritten = 0; @@ -442,6 +442,6 @@ void SendToTsfViaNamedpipe(UINT msg_type, std::wstring &pipeData) if (!ret || bytesWritten != pipeData.length() * sizeof(wchar_t)) { // TODO: Error handling - OutputDebugString(L"SendToTsfViaNamedpipe WriteFile failed"); + OutputDebugString(L"SendToTsfViaNamedpipe WriteFile failed\n"); } } \ No newline at end of file diff --git a/server/src/utils/webview_utils.cpp b/server/src/utils/webview_utils.cpp index eefc926a..db0c0e3f 100644 --- a/server/src/utils/webview_utils.cpp +++ b/server/src/utils/webview_utils.cpp @@ -93,7 +93,7 @@ void MoveContainerBottom(ComPtr webview, int marginTop) script.append(std::to_wstring(marginTop)); script.append(L"px';"); script.append(L"}"); - OutputDebugString(script.c_str()); + OutputDebugString((script + L"\n").c_str()); webview->ExecuteScript(script.c_str(), nullptr); } diff --git a/server/src/webview2/windows_webview2.cpp b/server/src/webview2/windows_webview2.cpp index 6817b9d1..a7b67777 100644 --- a/server/src/webview2/windows_webview2.cpp +++ b/server/src/webview2/windows_webview2.cpp @@ -399,7 +399,7 @@ HRESULT OnControllerCreatedMenuWnd( // { if (!controller || FAILED(result)) { - OutputDebugString(fmt::format(L"Failed to create menu window webview2 controller.").c_str()); + OutputDebugString(fmt::format(L"Failed to create menu window webview2 controller.\n").c_str()); return E_FAIL; } @@ -409,7 +409,7 @@ HRESULT OnControllerCreatedMenuWnd( // if (!webviewMenuWnd) { - OutputDebugString(fmt::format(L"Failed to get webview2 instance.").c_str()); + OutputDebugString(fmt::format(L"Failed to get webview2 instance.\n").c_str()); return E_FAIL; } @@ -452,7 +452,7 @@ HRESULT OnControllerCreatedMenuWnd( // HRESULT hr = webviewMenuWnd->NavigateToString(::HTMLStringMenuWnd.c_str()); if (FAILED(hr)) { - OutputDebugString(fmt::format(L"Failed to navigate to string.").c_str()); + OutputDebugString(fmt::format(L"Failed to navigate to string.\n").c_str()); } /* Debug console */ @@ -473,7 +473,7 @@ HRESULT OnMenuWindowEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebView2E { if (FAILED(result) || !env) { - OutputDebugString(fmt::format(L"Failed to create menu window webview2 environment.").c_str()); + OutputDebugString(fmt::format(L"Failed to create menu window webview2 environment.\n").c_str()); return result; } @@ -530,7 +530,7 @@ HRESULT OnControllerCreatedSettingsWnd( // { if (!controller || FAILED(result)) { - OutputDebugString(fmt::format(L"Failed to create settings window webview2 controller.").c_str()); + OutputDebugString(fmt::format(L"Failed to create settings window webview2 controller.\n").c_str()); return E_FAIL; } @@ -540,7 +540,7 @@ HRESULT OnControllerCreatedSettingsWnd( // if (!webviewSettingsWnd) { - OutputDebugString(fmt::format(L"Failed to get webview2 instance.").c_str()); + OutputDebugString(fmt::format(L"Failed to get webview2 instance.\n").c_str()); return E_FAIL; } @@ -588,7 +588,7 @@ HRESULT OnControllerCreatedSettingsWnd( // HRESULT hr = webviewSettingsWnd->Navigate(url.c_str()); if (FAILED(hr)) { - OutputDebugString(fmt::format(L"Failed to navigate to string.").c_str()); + OutputDebugString(fmt::format(L"Failed to navigate to string.\n").c_str()); } EventRegistrationToken navCompletedToken; @@ -628,7 +628,7 @@ HRESULT OnSettingsWindowEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebVi { if (FAILED(result) || !env) { - OutputDebugString(fmt::format(L"Failed to create settings window webview2 environment.").c_str()); + OutputDebugString(fmt::format(L"Failed to create settings window webview2 environment.\n").c_str()); return result; } @@ -685,7 +685,7 @@ HRESULT OnControllerCreatedFtbWnd( // { if (!controller || FAILED(result)) { - OutputDebugString(fmt::format(L"Failed to create floating toolbar window webview2 controller.").c_str()); + OutputDebugString(fmt::format(L"Failed to create floating toolbar window webview2 controller.\n").c_str()); return E_FAIL; } @@ -695,7 +695,7 @@ HRESULT OnControllerCreatedFtbWnd( // if (!webviewFtbWnd) { - OutputDebugString(fmt::format(L"Failed to get webview2 instance.").c_str()); + OutputDebugString(fmt::format(L"Failed to get webview2 instance.\n").c_str()); return E_FAIL; } @@ -738,7 +738,7 @@ HRESULT OnControllerCreatedFtbWnd( // HRESULT hr = webviewFtbWnd->NavigateToString(::HTMLStringFtbWnd.c_str()); if (FAILED(hr)) { - OutputDebugString(fmt::format(L"Failed to navigate to string.").c_str()); + OutputDebugString(fmt::format(L"Failed to navigate to string.\n").c_str()); } /* 使 floating toolbar 窗口可拖动 */ @@ -777,7 +777,7 @@ HRESULT OnFtbWindowEnvironmentCreated(HWND hwnd, HRESULT result, ICoreWebView2En { if (FAILED(result) || !env) { - OutputDebugString(fmt::format(L"Failed to create floating toolbar window webview2 environment.").c_str()); + OutputDebugString(fmt::format(L"Failed to create floating toolbar window webview2 environment.\n").c_str()); return result; } diff --git a/server/src/window/ime_windows.cpp b/server/src/window/ime_windows.cpp index 0d580e78..e501bc7e 100644 --- a/server/src/window/ime_windows.cpp +++ b/server/src/window/ime_windows.cpp @@ -266,7 +266,7 @@ int CreateCandidateWindow(HINSTANCE hInstance) OutputDebugString(fmt::format(L"键盘钩子安装失败\n").c_str()); return 1; } - OutputDebugString(fmt::format(L"键盘钩子安装成功").c_str()); + OutputDebugString(fmt::format(L"键盘钩子安装成功\n").c_str()); MSG msg; while (GetMessage(&msg, NULL, 0, 0)) @@ -374,7 +374,7 @@ LRESULT CALLBACK WndProcCandWindow(HWND hwnd, UINT message, WPARAM wParam, LPARA /* Clear dictionary buffer cache */ case WM_CLS_DICT_CACHE: { g_dictQuery->reset_cache(); - OutputDebugString(fmt::format(L"Cleared dictionary buffer cache.").c_str()); + OutputDebugString(fmt::format(L"Cleared dictionary buffer cache.\n").c_str()); break; }