1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-09 23:54:20 +00:00

Debug Log: can output to debugger. Added ImGuiDebugLogFlags_OutputToDebugger.

This commit is contained in:
ocornut 2025-12-05 15:07:44 +01:00
parent 9d4fafa671
commit ded52c71d9
3 changed files with 15 additions and 3 deletions

View file

@ -17560,14 +17560,23 @@ void ImGui::DebugLogV(const char* fmt, va_list args)
g.DebugLogBuf.appendf("[%05d] ", g.FrameCount);
g.DebugLogBuf.appendfv(fmt, args);
g.DebugLogIndex.append(g.DebugLogBuf.c_str(), old_size, g.DebugLogBuf.size());
const char* str = g.DebugLogBuf.begin() + old_size;
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToTTY)
IMGUI_DEBUG_PRINTF("%s", g.DebugLogBuf.begin() + old_size);
IMGUI_DEBUG_PRINTF("%s", str);
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToDebugger)
{
::OutputDebugStringA("[imgui] ");
::OutputDebugStringA(str);
}
#endif
#ifdef IMGUI_ENABLE_TEST_ENGINE
// IMGUI_TEST_ENGINE_LOG() adds a trailing \n automatically
const int new_size = g.DebugLogBuf.size();
const bool trailing_carriage_return = (g.DebugLogBuf[new_size - 1] == '\n');
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToTestEngine)
IMGUI_TEST_ENGINE_LOG("%.*s", new_size - old_size - (trailing_carriage_return ? 1 : 0), g.DebugLogBuf.begin() + old_size);
IMGUI_TEST_ENGINE_LOG("%.*s", new_size - old_size - (trailing_carriage_return ? 1 : 0), str);
#endif
}
@ -17647,6 +17656,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
if (BeginPopup("Outputs"))
{
CheckboxFlags("OutputToTTY", &g.DebugLogFlags, ImGuiDebugLogFlags_OutputToTTY);
CheckboxFlags("OutputToDebugger", &g.DebugLogFlags, ImGuiDebugLogFlags_OutputToDebugger);
#ifndef IMGUI_ENABLE_TEST_ENGINE
BeginDisabled();
#endif