playground/ExampleApps/ExampleAppLog.cpp
// Demonstrate creating a simple log window with basic filtering.
Demonstrate creating a simple log window with basic filtering.
Demonstrate creating a simple log window with basic filtering .
static void ShowExampleAppLog(bool* p_open)
{
    static ExampleAppLog log;
    ImGui::SetNextWindowSize(ImVec2(500, 400), ImGuiCond_FirstUseEver);
    ImGui::Begin("Example: Log", p_open);
    DEMO_MARKER("Examples/Log");
    if (ImGui::SmallButton("[Debug] Add 5 entries"))
    {
        static int counter = 0;
        const char* categories[3] = { "info", "warn", "error" };
        const char* words[] = { "Bumfuzzled", "Cattywampus", "Snickersnee", "Abibliophobia", "Absquatulate", "Nincompoop", "Pauciloquent" };
        for (int n = 0; n < 5; n++)
        {
            const char* category = categories[counter % IM_ARRAYSIZE(categories)];
            const char* word = words[counter % IM_ARRAYSIZE(words)];
            log.AddLog("[%05d] [%s] Hello, current time is %.1f, here's a word: '%s'\n",
                ImGui::GetFrameCount(), category, ImGui::GetTime(), word);
            counter++;
        }
    }
    ImGui::End();
    log.Draw("Example: Log", p_open);
}
static void ShowExampleAppLog ( bool * p_open ) { static ExampleAppLog log ; ImGui :: SetNextWindowSize ( ImVec2 ( 500 , 400 ) , ImGuiCond_FirstUseEver ) ; ImGui :: Begin ( " " , p_open ) ; DEMO_MARKER ( " " ) ; if ( ImGui :: SmallButton ( " " ) ) { static int counter = 0 ; const char * categories [ 3 ] = { " " , " " , " " } ; const char * words [ ] = { " " , " " , " " , " " , " " , " " , " " } ; for ( int n = 0 ; n < 5 ; n ++ ) { const char * category = categories [ counter % IM_ARRAYSIZE ( categories ) ] ; const char * word = words [ counter % IM_ARRAYSIZE ( words ) ] ; log . AddLog ( " \n " , ImGui :: GetFrameCount ( ) , category , ImGui :: GetTime ( ) , word ) ; counter ++ ; } } ImGui :: End ( ) ; log . Draw ( " " , p_open ) ; }
Demonstrate creating a simple log window with basic filtering.
Demonstrate creating a simple log window with basic filtering .
// For the demo: add a debug button _BEFORE_ the normal log window contents // We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window. // Most of the contents of the window will be added by the log.Draw() call. // Actually call in the regular Log helper (which will Begin() into the same window as we just did)