Abstract logger interface defining stream-style logging operations.
More...
#include <headers/utility/logging/logger.hpp>
|
| | Logger (const std::string &name) |
| | Default constructor.
|
| |
|
virtual | ~Logger (void)=default |
| | Virtual destructor for proper cleanup.
|
| |
| void | setMinLevel (LogLevel level) noexcept |
| | Set the minimum log level. Messages below this level are suppressed.
|
| |
| LogLevel | getMinLevel (void) const noexcept |
| | Get the current minimum log level.
|
| |
| void | setFlushPolicy (FlushPolicy policy) noexcept |
| | Set the output flush policy.
|
| |
| FlushPolicy | getFlushPolicy (void) const noexcept |
| | Get the current output flush policy.
|
| |
| LogMessage | debug (std::source_location loc=std::source_location::current()) |
| | Begin a debug-level log message.
|
| |
| LogMessage | info (std::source_location loc=std::source_location::current()) |
| | Begin an info-level log message.
|
| |
| LogMessage | warning (std::source_location loc=std::source_location::current()) |
| | Begin a warning-level log message.
|
| |
| LogMessage | error (std::source_location loc=std::source_location::current()) |
| | Begin an error-level log message.
|
| |
| LogMessage | log (LogLevel level, std::source_location loc=std::source_location::current()) |
| | Begin a log message with dynamic level.
|
| |
| virtual void | output (const LogRecord &record)=0 |
| | Output a fully-formed log record.
|
| |
| const std::string & | getName (void) const |
| | Get the logger name.
|
| |
|
| static constexpr LogLevel | defaultMinLevel (void) noexcept |
| | Default minimum level for the current build type.
|
| |
| static std::string | levelToString (LogLevel level) |
| | Get string representation of log level.
|
| |
| static std::string | getTimestamp (void) |
| | Get current timestamp as formatted string.
|
| |
| static constexpr int | levelValue (LogLevel level) noexcept |
| | Get numeric value of a log level for comparison.
|
| |
|
| std::mutex | _mutex |
| | Serializes output access.
|
| |
Abstract logger interface defining stream-style logging operations.
Implementations derive from Logger and override output(const LogRecord&) to handle formatted output.
Definition at line 95 of file logger.hpp.
◆ Logger()
| utility::logging::Logger::Logger |
( |
const std::string & |
name | ) |
|
Default constructor.
- Parameters
-
| name | The name of the logger. |
Definition at line 116 of file logger.cpp.
◆ debug()
| LogMessage utility::logging::Logger::debug |
( |
std::source_location |
loc = std::source_location::current() | ) |
|
|
inline |
Begin a debug-level log message.
- Parameters
-
| loc | Source location (auto-captured). |
- Returns
- LogMessage proxy for streaming.
Definition at line 336 of file logger.hpp.
◆ defaultMinLevel()
| static constexpr LogLevel utility::logging::Logger::defaultMinLevel |
( |
void |
| ) |
|
|
inlinestaticconstexprnoexcept |
Default minimum level for the current build type.
Release builds (NDEBUG) default to WARNING_LEVEL so hot-loop debug/info calls are suppressed; debug builds keep DEBUG_LEVEL. The UTILITY_LOG_LEVEL environment variable (debug/info/warning/error) overrides this at construction.
- Returns
- The default minimum level.
Definition at line 255 of file logger.hpp.
◆ error()
| LogMessage utility::logging::Logger::error |
( |
std::source_location |
loc = std::source_location::current() | ) |
|
|
inline |
Begin an error-level log message.
- Parameters
-
| loc | Source location (auto-captured). |
- Returns
- LogMessage proxy for streaming.
Definition at line 372 of file logger.hpp.
◆ getFlushPolicy()
| FlushPolicy utility::logging::Logger::getFlushPolicy |
( |
void |
| ) |
const |
|
noexcept |
Get the current output flush policy.
- Returns
- The active flush policy.
Definition at line 144 of file logger.cpp.
◆ getMinLevel()
| LogLevel utility::logging::Logger::getMinLevel |
( |
void |
| ) |
const |
|
noexcept |
Get the current minimum log level.
- Returns
- Minimum emitted level.
Definition at line 134 of file logger.cpp.
◆ getName()
| const std::string & utility::logging::Logger::getName |
( |
void |
| ) |
const |
|
inline |
Get the logger name.
- Returns
- The name of this logger.
Definition at line 401 of file logger.hpp.
◆ getTimestamp()
| std::string utility::logging::Logger::getTimestamp |
( |
void |
| ) |
|
|
static |
Get current timestamp as formatted string.
- Returns
- Formatted timestamp string.
Definition at line 87 of file logger.cpp.
◆ info()
| LogMessage utility::logging::Logger::info |
( |
std::source_location |
loc = std::source_location::current() | ) |
|
|
inline |
Begin an info-level log message.
- Parameters
-
| loc | Source location (auto-captured). |
- Returns
- LogMessage proxy for streaming.
Definition at line 348 of file logger.hpp.
◆ levelToString()
| std::string utility::logging::Logger::levelToString |
( |
LogLevel |
level | ) |
|
|
static |
Get string representation of log level.
- Parameters
-
| level | The log level to convert. |
- Returns
- String representation of the level.
Definition at line 71 of file logger.cpp.
◆ levelValue()
| static constexpr int utility::logging::Logger::levelValue |
( |
LogLevel |
level | ) |
|
|
inlinestaticconstexprnoexcept |
Get numeric value of a log level for comparison.
Inline and constexpr so the call-site filter is a single comparison that the optimizer can fold.
- Parameters
-
- Returns
- Integer value (Debug=0, Info=1, Warning=2, Error=3); unknown levels map to a high sentinel so they are never silently dropped.
Definition at line 312 of file logger.hpp.
◆ log()
| LogMessage utility::logging::Logger::log |
( |
LogLevel |
level, |
|
|
std::source_location |
loc = std::source_location::current() |
|
) |
| |
|
inline |
Begin a log message with dynamic level.
- Parameters
-
| level | Severity level. |
| loc | Source location (auto-captured). |
- Returns
- LogMessage proxy for streaming.
Definition at line 385 of file logger.hpp.
◆ output()
| virtual void utility::logging::Logger::output |
( |
const LogRecord & |
record | ) |
|
|
pure virtual |
◆ setFlushPolicy()
| void utility::logging::Logger::setFlushPolicy |
( |
FlushPolicy |
policy | ) |
|
|
noexcept |
Set the output flush policy.
- Parameters
-
| policy | The flush policy to apply. |
Definition at line 139 of file logger.cpp.
◆ setMinLevel()
| void utility::logging::Logger::setMinLevel |
( |
LogLevel |
level | ) |
|
|
noexcept |
Set the minimum log level. Messages below this level are suppressed.
- Parameters
-
| level | Minimum level to emit. |
Definition at line 129 of file logger.cpp.
◆ warning()
| LogMessage utility::logging::Logger::warning |
( |
std::source_location |
loc = std::source_location::current() | ) |
|
|
inline |
Begin a warning-level log message.
- Parameters
-
| loc | Source location (auto-captured). |
- Returns
- LogMessage proxy for streaming.
Definition at line 360 of file logger.hpp.
◆ _mutex
| std::mutex utility::logging::Logger::_mutex |
|
mutableprotected |
Serializes output access.
Definition at line 122 of file logger.hpp.
The documentation for this class was generated from the following files: