Skip to main content

ImGuiLogSink.ixx File

Log sink that forwards messages to a LogWidget. More...

Included Headers

#include <string> #include <helios.imgui.widgets.LogWidget> #include <helios.engine.util.log.LogSink>

Namespaces Index

namespacehelios
namespaceimgui

Classes Index

classImGuiLogSink

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

Description

Log sink that forwards messages to a LogWidget.

File Listing

The file content with the documentation metadata removed is:

1
5module;
6
7#include <string>
8
9export module helios.imgui.ImGuiLogSink;
10
11import helios.engine.util.log.LogSink;
12import helios.imgui.widgets.LogWidget;
13
14export namespace helios::imgui {
15
32 class ImGuiLogSink : public helios::engine::util::log::LogSink {
33
34 private:
38 widgets::LogWidget* widget_ = nullptr;
39
40 public:
44 static constexpr helios::engine::util::log::SinkTypeId TYPE_ID = "imgui";
45
53 : widget_(widget) {}
54
60 [[nodiscard]] helios::engine::util::log::SinkTypeId typeId() const noexcept override {
61 return TYPE_ID;
62 }
63
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 }
93 };
94
95}
96

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.