A thread-safe Singleton class responsible for logging system events.
More...
#include <Logger.hxx>
|
| | Logger (const std::string &name) |
| | Constructor.
|
|
| ~Logger () override |
| | Destructor.
|
| void | update (const Event &event) override |
| | Method called by the Subject to notify the observer with an event.
|
| void | notify (const Event &event) override |
| | Method called by the subject to notify the observer.
|
| void | debug (const std::string &message) |
| | Logs a message at the DEBUG level.
|
| void | info (const std::string &message) |
| | Logs a message at the INFO level.
|
| void | warn (const std::string &message) |
| | Logs a message at the WARN level.
|
| void | error (const std::string &message) |
| | Logs a message at the ERROR level.
|
| void | fatal (const std::string &message) |
| | Logs a message at the FATAL level.
|
| void | setLevel (LogLevel level) |
| | Sets the minimum log level for this instance.
|
| LogLevel | getLevel () const |
| | Retrieves the current minimum log level.
|
| void | setPattern (const std::string &pattern) |
| | Sets the output formatting pattern for messages.
|
|
void | flush () |
| | Forces all buffered log output to be written immediately (e.g., to disk).
|
| virtual | ~IObserver ()=default |
| | Default virtual destructor.
|
|
| static std::shared_ptr< Logger > | getInstance (const std::string &name) |
| | Retrieves the Singleton instance of the Logger for the given name.
|
| static void | clearInstances () |
| | Clears all registered Singleton instances.
|
A thread-safe Singleton class responsible for logging system events.
Implements the IObserver interface to automatically receive and process events generated by commands and core components.
◆ Logger()
| svcs::services::Logger::Logger |
( |
const std::string & | name | ) |
|
|
explicit |
Constructor.
Private/protected access is typically enforced in the Singleton implementation file.
- Parameters
-
| name | The unique name for this logger instance. |
◆ clearInstances()
| void svcs::services::Logger::clearInstances |
( |
| ) |
|
|
static |
Clears all registered Singleton instances.
Used primarily for cleanup in testing environments.
◆ debug()
| void svcs::services::Logger::debug |
( |
const std::string & | message | ) |
|
Logs a message at the DEBUG level.
- Parameters
-
| message | The content of the log message. |
◆ error()
| void svcs::services::Logger::error |
( |
const std::string & | message | ) |
|
Logs a message at the ERROR level.
- Parameters
-
| message | The content of the log message. |
◆ fatal()
| void svcs::services::Logger::fatal |
( |
const std::string & | message | ) |
|
Logs a message at the FATAL level.
- Parameters
-
| message | The content of the log message. |
◆ getInstance()
| std::shared_ptr< Logger > svcs::services::Logger::getInstance |
( |
const std::string & | name | ) |
|
|
static |
Retrieves the Singleton instance of the Logger for the given name.
Creates and registers a new instance if one does not already exist.
- Parameters
-
| name | The name of the desired logger instance. |
- Returns
- A shared pointer to the Logger instance.
◆ getLevel()
| LogLevel svcs::services::Logger::getLevel |
( |
| ) |
const |
|
nodiscard |
Retrieves the current minimum log level.
- Returns
- The current LogLevel.
◆ info()
| void svcs::services::Logger::info |
( |
const std::string & | message | ) |
|
Logs a message at the INFO level.
- Parameters
-
| message | The content of the log message. |
◆ notify()
| void svcs::services::Logger::notify |
( |
const Event & | event | ) |
|
|
overridevirtual |
◆ setLevel()
| void svcs::services::Logger::setLevel |
( |
LogLevel | level | ) |
|
Sets the minimum log level for this instance.
- Parameters
-
◆ setPattern()
| void svcs::services::Logger::setPattern |
( |
const std::string & | pattern | ) |
|
Sets the output formatting pattern for messages.
- Parameters
-
| pattern | The new format string (implementation details depend on pattern syntax). |
◆ update()
| void svcs::services::Logger::update |
( |
const Event & | event | ) |
|
|
overridevirtual |
◆ warn()
| void svcs::services::Logger::warn |
( |
const std::string & | message | ) |
|
Logs a message at the WARN level.
- Parameters
-
| message | The content of the log message. |
The documentation for this class was generated from the following files: