Skip to main content

ImGuiLogSink Class

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

Declaration

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

Base class

classhelios::engine::util::log::LogSink

Public Constructors Index

ImGuiLogSink (widgets::LogWidget *widget)

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

Public Member Functions Index

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

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

voidwrite (helios::engine::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::engine::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.

 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::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::engine::util::log::SinkTypeId helios::imgui::ImGuiLogSink::typeId ()
inline noexcept

Returns the unique type identifier for this sink.

Returns

"imgui".

Definition at line 60 of file ImGuiLogSink.ixx.

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

Reference TYPE_ID.

write()

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

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.

71 void write(helios::engine::util::log::LogLevel level,
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) {
79 case helios::engine::util::log::LogLevel::Debug:
80 widgetLevel = widgets::LogLevel::Debug; break;
81 case helios::engine::util::log::LogLevel::Info:
82 widgetLevel = widgets::LogLevel::Info; break;
83 case helios::engine::util::log::LogLevel::Warn:
84 widgetLevel = widgets::LogLevel::Warn; break;
85 case helios::engine::util::log::LogLevel::Error:
86 widgetLevel = widgets::LogLevel::Error; break;
87 default:
88 widgetLevel = widgets::LogLevel::Info;
89 }
90
91 widget_->addLog(widgetLevel, scope, message);
92 }

References helios::imgui::widgets::LogWidget::addLog, helios::imgui::widgets::Debug, helios::imgui::widgets::Error, helios::imgui::widgets::Info and helios::imgui::widgets::Warn.

Private Member Attributes

widget_

widgets::LogWidget* helios::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

constexpr helios::engine::util::log::SinkTypeId helios::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::engine::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.9.8.