Logger Class
Logger implementation with configurable output sinks. More...
Declaration
Public Constructors Index
| Logger (std::string scope) | |
Public Member Functions Index
| void | enable (bool enable) noexcept |
|
Enables or disables log output for this Logger instance. More... | |
| void | addSink (std::shared_ptr< LogSink > sink) |
|
Adds an output sink to this logger. More... | |
| void | clearSinks () noexcept |
|
Removes all sinks from this logger. More... | |
| size_t | sinkCount () const noexcept |
|
Returns the number of attached sinks. More... | |
| void | warn (const std::string &msg) const noexcept |
|
Writes a warning message if logging is enabled. More... | |
| void | debug (const std::string &msg) const noexcept |
|
Writes a debug message if logging is enabled. More... | |
| void | info (const std::string &msg) const noexcept |
|
Writes an info message if logging is enabled. More... | |
| void | error (const std::string &msg) const noexcept |
|
Writes an error message if logging is enabled. More... | |
Private Member Functions Index
| void | dispatch (LogLevel level, const std::string &msg) const noexcept |
|
Dispatches a message to all registered sinks. More... | |
Private Member Attributes Index
| const std::string | scope_ = "default" |
| bool | enabled_ = true |
|
Flag to indicate whether this Logger's output is enabled. More... | |
| std::vector< std::shared_ptr< LogSink > > | sinks_ |
|
Collection of output sinks. More... | |
| std::mutex | sinkMutex_ |
|
Mutex for thread-safe sink access. More... | |
Description
Logger implementation with configurable output sinks.
This logger supports multiple output destinations through LogSink instances. By default, it writes to stdout, but sinks can be added or replaced to redirect output to ImGui widgets, files, or other destinations.
```cpp // Add ImGui sink while keeping console output logger.addSink(imguiSink);
// Replace all sinks (ImGui only) logger.clearSinks(); logger.addSink(imguiSink); ```
Definition at line 35 of file Logger.ixx.
Public Constructors
Logger()
| inline explicit |
Creates a new Logger, tagged with a specific scope.
- Parameters
-
scope The textual scope used as a prefix in log output (e.g. "helios::rendering").
Definition at line 90 of file Logger.ixx.
Public Member Functions
addSink()
| inline |
Adds an output sink to this logger.
- Parameters
-
sink Shared pointer to the sink to add.
Definition at line 107 of file Logger.ixx.
clearSinks()
| inline noexcept |
Removes all sinks from this logger.
Definition at line 115 of file Logger.ixx.
debug()
| inline noexcept |
Writes a debug message if logging is enabled.
- Parameters
-
msg The message to write.
Definition at line 144 of file Logger.ixx.
Reference helios::util::log::Debug.
enable()
| inline noexcept |
error()
| inline noexcept |
Writes an error message if logging is enabled.
- Parameters
-
msg The message to write.
Definition at line 162 of file Logger.ixx.
Reference helios::util::log::Error.
info()
| inline noexcept |
Writes an info message if logging is enabled.
- Parameters
-
msg The message to write.
Definition at line 153 of file Logger.ixx.
Reference helios::util::log::Info.
sinkCount()
| inline nodiscard noexcept |
Returns the number of attached sinks.
- Returns
The number of sinks currently attached to this logger.
Definition at line 125 of file Logger.ixx.
warn()
| inline noexcept |
Writes a warning message if logging is enabled.
- Parameters
-
msg The message to write.
Definition at line 135 of file Logger.ixx.
Reference helios::util::log::Warn.
Private Member Functions
dispatch()
| inline noexcept |
Dispatches a message to all registered sinks.
- Parameters
-
level The log level of the message.
msg The message to dispatch.
Definition at line 61 of file Logger.ixx.
Private Member Attributes
enabled_
|
Flag to indicate whether this Logger's output is enabled.
Definition at line 43 of file Logger.ixx.
scope_
|
Definition at line 38 of file Logger.ixx.
sinkMutex_
| mutable |
Mutex for thread-safe sink access.
Definition at line 53 of file Logger.ixx.
sinks_
|
Collection of output sinks.
Definition at line 48 of file Logger.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.