class mrpt::imgui::CImGuiLogConsole

Overview

A dockable log console: a rolling buffer of messages, e.g.

from any number of mrpt::system::COutputLogger objects, with filters by minimum level, source and text, autoscroll, and saving to a file.

Messages can be pushed from any thread; render() must be called from the GUI thread.

mrpt::imgui::CImGuiLogConsole console;
console.attach(myAlgorithm);  // any COutputLogger
// In a window:
console.render();
#include <mrpt/imgui/CImGuiLogConsole.h>

class CImGuiLogConsole
{
public:
    // structs

    struct Entry;
    struct Filter;

    // fields

    std::atomic<size_t> maxEntries {20000};
    Filter filter;
    bool autoScroll = true;
    bool showTimestamps = true;
    bool showSources = true;

    // construction

    CImGuiLogConsole();
    CImGuiLogConsole(const CImGuiLogConsole&);

    // methods

    CImGuiLogConsole& operator = (const CImGuiLogConsole&);

    void push(
        mrpt::system::VerbosityLevel level,
        const std::string& source,
        const std::string& text,
        mrpt::Clock::time_point timestamp = mrpt::Clock::now()
        );

    void attach(mrpt::system::COutputLogger& logger);
    void detach(mrpt::system::COutputLogger& logger);
    void clear();
    size_t size() const;
    uint64_t version() const;
    std::vector<std::string> sources() const;
    std::vector<Entry> filtered() const;
    std::string filteredAsText() const;
    std::string format(const Entry& e) const;
    void render();
};

Fields

std::atomic<size_t> maxEntries {20000}

Oldest messages are dropped beyond this count.

Methods

void push(
    mrpt::system::VerbosityLevel level,
    const std::string& source,
    const std::string& text,
    mrpt::Clock::time_point timestamp = mrpt::Clock::now()
    )

Adds a message (thread-safe).

Multi-line text becomes one entry per line; a trailing newline is ignored.

void attach(mrpt::system::COutputLogger& logger)

Receives all messages of a logger, from now on.

The logger must outlive this object, or be detached first.

uint64_t version() const

Incremented on every change, for cheap change detection.

std::vector<std::string> sources() const

All the sources seen so far.

std::vector<Entry> filtered() const

A copy of the entries that pass the filter.

std::string filteredAsText() const

The entries that pass the filter, as text, one per line.

std::string format(const Entry& e) const

Formats one entry as a text line.

void render()

Draws the filter toolbar and the messages in the current window.