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... | |
| std::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... | |
template <typename... TArgs> | |
| void | warn (std::format_string< TArgs... > fmt, TArgs &&... args) const |
|
Writes a formatted warning message if logging is enabled. More... | |
| void | debug (const std::string &msg) const noexcept |
|
Writes a debug message if logging is enabled. More... | |
template <typename... TArgs> | |
| void | debug (std::format_string< TArgs... > fmt, TArgs &&... args) const |
|
Writes a formatted debug message if logging is enabled. More... | |
| void | info (const std::string &msg) const noexcept |
|
Writes an info message if logging is enabled. More... | |
template <typename... TArgs> | |
| void | info (std::format_string< TArgs... > fmt, TArgs &&... args) const |
|
Writes a formatted info message if logging is enabled. More... | |
| void | error (const std::string &msg) const noexcept |
|
Writes an error message if logging is enabled. More... | |
template <typename... TArgs> | |
| void | error (std::format_string< TArgs... > fmt, TArgs &&... args) const |
|
Writes a formatted 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... | |
template <typename... TArgs> | |
| void | dispatchFormatted (LogLevel level, std::format_string< TArgs... > fmt, TArgs &&... args) const |
|
Formats a message and dispatches it to all 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. In addition to plain string messages, the logger also supports std::format-based message creation.
Definition at line 42 of file Logger.ixx.
Public Constructors
Logger()
| inline explicit |
Public Member Functions
addSink()
| inline |
Adds an output sink to this logger.
- Parameters
-
sink Shared pointer to the sink to add.
Definition at line 127 of file Logger.ixx.
Reference helios::registerComponents.
clearSinks()
| inline noexcept |
Removes all sinks from this logger.
Definition at line 135 of file Logger.ixx.
debug()
| inline noexcept |
Writes a debug message if logging is enabled.
- Parameters
-
msg The message to write.
Definition at line 176 of file Logger.ixx.
References helios::engine::util::log::Debug and helios::registerComponents.
debug()
| inline |
Writes a formatted debug message if logging is enabled.
- Template Parameters
-
TArgs Format argument types.
- Parameters
-
fmt Checked format string.
args Format arguments.
Definition at line 188 of file Logger.ixx.
References helios::engine::util::log::Debug and helios::registerComponents.
enable()
| inline noexcept |
error()
| inline noexcept |
Writes an error message if logging is enabled.
- Parameters
-
msg The message to write.
Definition at line 218 of file Logger.ixx.
References helios::engine::util::log::Error and helios::registerComponents.
Referenced by helios::engine::util::io::BasicStringFileReader::getContents and helios::engine::util::io::BasicStringFileReader::readInto.
error()
| inline |
Writes a formatted error message if logging is enabled.
- Template Parameters
-
TArgs Format argument types.
- Parameters
-
fmt Checked format string.
args Format arguments.
Definition at line 230 of file Logger.ixx.
References helios::engine::util::log::Error and helios::registerComponents.
info()
| inline noexcept |
Writes an info message if logging is enabled.
- Parameters
-
msg The message to write.
Definition at line 197 of file Logger.ixx.
References helios::engine::util::log::Info and helios::registerComponents.
info()
| inline |
Writes a formatted info message if logging is enabled.
- Template Parameters
-
TArgs Format argument types.
- Parameters
-
fmt Checked format string.
args Format arguments.
Definition at line 209 of file Logger.ixx.
References helios::engine::util::log::Info and helios::registerComponents.
sinkCount()
| inline noexcept |
warn()
| inline noexcept |
Writes a warning message if logging is enabled.
- Parameters
-
msg The message to write.
Definition at line 155 of file Logger.ixx.
References helios::registerComponents and helios::engine::util::log::Warn.
Referenced by helios::engine::input::InputManager::registerGamepads and helios::engine::input::gamepad::GamepadState::updateAxes.
warn()
| inline |
Writes a formatted warning message if logging is enabled.
- Template Parameters
-
TArgs Format argument types.
- Parameters
-
fmt Checked format string.
args Format arguments.
Definition at line 167 of file Logger.ixx.
References helios::registerComponents and helios::engine::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 68 of file Logger.ixx.
dispatchFormatted()
| inline |
Formats a message and dispatches it to all sinks.
- Template Parameters
-
TArgs Format argument types.
- Parameters
-
level Log level of the message.
fmt Checked format string.
args Format arguments.
Definition at line 100 of file Logger.ixx.
Private Member Attributes
enabled_
|
Flag to indicate whether this Logger's output is enabled.
Definition at line 50 of file Logger.ixx.
scope_
|
Definition at line 45 of file Logger.ixx.
sinkMutex_
| mutable |
Mutex for thread-safe sink access.
Definition at line 60 of file Logger.ixx.
sinks_
|
Collection of output sinks.
Definition at line 55 of file Logger.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.