Skip to content

Commit ded52c7

Browse files
committed
Debug Log: can output to debugger. Added ImGuiDebugLogFlags_OutputToDebugger.
1 parent 9d4fafa commit ded52c7

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

docs/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Other Changes:
7272
- Debug Tools:
7373
- Debug Log: fixed incorrectly printing characters in IO log when submitting
7474
non-ASCII values to io.AddInputCharacter(). (#9099)
75+
- Debug Log: can output to debugger on Windows. (#5855)
7576
- Backends:
7677
- SDL_GPU3: macOS version can use MSL shaders in order to support macOS 10.14+
7778
(vs Metallib shaders requiring macOS 14+). Requires application calling

imgui.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17560,14 +17560,23 @@ void ImGui::DebugLogV(const char* fmt, va_list args)
1756017560
g.DebugLogBuf.appendf("[%05d] ", g.FrameCount);
1756117561
g.DebugLogBuf.appendfv(fmt, args);
1756217562
g.DebugLogIndex.append(g.DebugLogBuf.c_str(), old_size, g.DebugLogBuf.size());
17563+
17564+
const char* str = g.DebugLogBuf.begin() + old_size;
1756317565
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToTTY)
17564-
IMGUI_DEBUG_PRINTF("%s", g.DebugLogBuf.begin() + old_size);
17566+
IMGUI_DEBUG_PRINTF("%s", str);
17567+
#if defined(_WIN32) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
17568+
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToDebugger)
17569+
{
17570+
::OutputDebugStringA("[imgui] ");
17571+
::OutputDebugStringA(str);
17572+
}
17573+
#endif
1756517574
#ifdef IMGUI_ENABLE_TEST_ENGINE
1756617575
// IMGUI_TEST_ENGINE_LOG() adds a trailing \n automatically
1756717576
const int new_size = g.DebugLogBuf.size();
1756817577
const bool trailing_carriage_return = (g.DebugLogBuf[new_size - 1] == '\n');
1756917578
if (g.DebugLogFlags & ImGuiDebugLogFlags_OutputToTestEngine)
17570-
IMGUI_TEST_ENGINE_LOG("%.*s", new_size - old_size - (trailing_carriage_return ? 1 : 0), g.DebugLogBuf.begin() + old_size);
17579+
IMGUI_TEST_ENGINE_LOG("%.*s", new_size - old_size - (trailing_carriage_return ? 1 : 0), str);
1757117580
#endif
1757217581
}
1757317582

@@ -17647,6 +17656,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
1764717656
if (BeginPopup("Outputs"))
1764817657
{
1764917658
CheckboxFlags("OutputToTTY", &g.DebugLogFlags, ImGuiDebugLogFlags_OutputToTTY);
17659+
CheckboxFlags("OutputToDebugger", &g.DebugLogFlags, ImGuiDebugLogFlags_OutputToDebugger);
1765017660
#ifndef IMGUI_ENABLE_TEST_ENGINE
1765117661
BeginDisabled();
1765217662
#endif

imgui_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,8 @@ enum ImGuiDebugLogFlags_
20782078

20792079
ImGuiDebugLogFlags_EventMask_ = ImGuiDebugLogFlags_EventError | ImGuiDebugLogFlags_EventActiveId | ImGuiDebugLogFlags_EventFocus | ImGuiDebugLogFlags_EventPopup | ImGuiDebugLogFlags_EventNav | ImGuiDebugLogFlags_EventClipper | ImGuiDebugLogFlags_EventSelection | ImGuiDebugLogFlags_EventIO | ImGuiDebugLogFlags_EventFont | ImGuiDebugLogFlags_EventInputRouting | ImGuiDebugLogFlags_EventDocking | ImGuiDebugLogFlags_EventViewport,
20802080
ImGuiDebugLogFlags_OutputToTTY = 1 << 20, // Also send output to TTY
2081-
ImGuiDebugLogFlags_OutputToTestEngine = 1 << 21, // Also send output to Test Engine
2081+
ImGuiDebugLogFlags_OutputToDebugger = 1 << 21, // Also send output to Debugger Console [Windows only]
2082+
ImGuiDebugLogFlags_OutputToTestEngine = 1 << 22, // Also send output to Dear ImGui Test Engine
20822083
};
20832084

20842085
struct ImGuiDebugAllocEntry

0 commit comments

Comments
 (0)