Skip to main content

ImGuiLogSink Class

LogSink implementation that forwards messages to a LogWidget. More...

Declaration

class helios::ext::imgui::ImGuiLogSink { ... }

Base class

classhelios::util::log::LogSink

Public Constructors Index

ImGuiLogSink (widgets::LogWidget *widget)

Constructs an ImGuiLogSink attached to a LogWidget. More...

Public Member Functions Index

helios::util::log::SinkTypeIdtypeId () const noexcept override

Returns the unique type identifier for this sink. More...

voidwrite (helios::util::log::LogLevel level, const std::string &scope, const std::string &message) override

Forwards a log message to the LogWidget. More...

Private Member Attributes Index

widgets::LogWidget *widget_ = nullptr

Pointer to the LogWidget to forward messages to. More...

Public Static Attributes Index

static constexpr helios::util::log::SinkTypeIdTYPE_ID = "imgui"

Unique type identifier for this sink. More...

Description

LogSink implementation that forwards messages to a LogWidget.

This sink bridges the helios logging system with the ImGui-based LogWidget, allowing log output to be displayed in the debug overlay instead of (or in addition to) the console.

```cpp auto logWidget = std::make_shared<widgets::LogWidget>(); overlay.addWidget(logWidget.get());

auto sink = std::make_shared<ImGuiLogSink>(logWidget.get()); LogManager::getInstance().registerSink(sink); ```

Definition at line 32 of file ImGuiLogSink.ixx.

Public Constructors

ImGuiLogSink()

helios::ext::imgui::ImGuiLogSink::ImGuiLogSink (widgets::LogWidget * widget)
inline explicit

Constructs an ImGuiLogSink attached to a LogWidget.

Parameters
widget

Pointer to the LogWidget to receive messages. Must remain valid for the lifetime of this sink.

Definition at line 52 of file ImGuiLogSink.ixx.

53 : widget_(widget) {}

Public Member Functions

typeId()

helios::util::log::SinkTypeId helios::ext::imgui::ImGuiLogSink::typeId ()
inline nodiscard noexcept virtual

Returns the unique type identifier for this sink.

Returns

"imgui".

Definition at line 60 of file ImGuiLogSink.ixx.

60 [[nodiscard]] helios::util::log::SinkTypeId typeId() const noexcept override {
61 return TYPE_ID;
62 }

Reference TYPE_ID.

write()

void helios::ext::imgui::ImGuiLogSink::write (helios::util::log::LogLevel level, const std::string & scope, const std::string & message)
inline virtual

Forwards a log message to the LogWidget.

Parameters
level

The severity level of the message.

scope

The source scope/module name.

message

The log message text.

Definition at line 71 of file ImGuiLogSink.ixx.

72 const std::string& scope,
73 const std::string& message) override {
74 if (!widget_) return;
75
76 // Map LogLevel to LogWidget's LogLevel
77 widgets::LogLevel widgetLevel;
78 switch (level) {
80 widgetLevel = widgets::LogLevel::Debug; break;
82 widgetLevel = widgets::LogLevel::Info; break;
84 widgetLevel = widgets::LogLevel::Warn; break;
86 widgetLevel = widgets::LogLevel::Error; break;
87 default:
88 widgetLevel = widgets::LogLevel::Info;
89 }
90
91 widget_->addLog(widgetLevel, scope, message);
92 }

References helios::ext::imgui::widgets::Debug, helios::util::log::Debug, helios::ext::imgui::widgets::Error, helios::util::log::Error, helios::ext::imgui::widgets::Info, helios::util::log::Info, helios::ext::imgui::widgets::Warn and helios::util::log::Warn.

Private Member Attributes

widget_

widgets::LogWidget* helios::ext::imgui::ImGuiLogSink::widget_ = nullptr

Pointer to the LogWidget to forward messages to.

Definition at line 38 of file ImGuiLogSink.ixx.

38 widgets::LogWidget* widget_ = nullptr;

Public Static Attributes

TYPE_ID

helios::util::log::SinkTypeId helios::ext::imgui::ImGuiLogSink::TYPE_ID = "imgui"
constexpr static

Unique type identifier for this sink.

Definition at line 44 of file ImGuiLogSink.ixx.

44 static constexpr helios::util::log::SinkTypeId TYPE_ID = "imgui";

Referenced by typeId.


The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.