23template <
typename LogSink = sinks::ConsoleLogSink, std::
size_t MaxMessageSize = 256>
51 [[nodiscard]]
const char*
category() const noexcept
57 [[nodiscard]] LogSink&
sink() noexcept {
return _sink; }
58 [[nodiscard]]
const LogSink&
sink() const noexcept {
return _sink; }
61 template <
typename... Args>
62 void log(
LogLevel level,
const char* fmt, Args&&... args)
const
70 event.category = _category;
72 if constexpr (
sizeof...(Args) == 0) {
73 event.setMessage(fmt);
75 int written = std::snprintf(event.message.data(), MaxMessageSize, fmt, std::forward<Args>(args)...);
77 event.length =
static_cast<std::size_t
>(written) < MaxMessageSize ?
static_cast<std::size_t
>(written) : (MaxMessageSize - 1);
85 template <
typename TargetEventSink,
typename... Args>
86 void logToSink(TargetEventSink&& targetSink,
LogLevel level,
const char* fmt, Args&&... args)
const
94 event.category = _category;
96 if constexpr (
sizeof...(Args) == 0) {
97 event.setMessage(fmt);
99 int written = std::snprintf(event.message.data(), MaxMessageSize, fmt, std::forward<Args>(args)...);
101 event.length =
static_cast<std::size_t
>(written) < MaxMessageSize ?
static_cast<std::size_t
>(written) : (MaxMessageSize - 1);
105 targetSink.post(std::move(event));
108 template <
typename... Args>
111 template <
typename... Args>
114 template <
typename... Args>
117 template <
typename... Args>
120 template <
typename... Args>
123 template <
typename... Args>
127 const char* _category =
"App";
Standard console output log sink with ANSI color support.
Synchronous append-only file logging sink.
Zero-heap fixed-capacity inline buffer log event record.
No-op compile-time disabled log sink for zero overhead.
Static compile-time logger wrapper managing severity level filtering and zero-heap string formatting.
Definition Logger.hpp:24
LogSink & sink() noexcept
Access underlying log sink reference.
Definition Logger.hpp:57
void debug(const char *fmt, Args &&... args) const
Definition Logger.hpp:112
void error(const char *fmt, Args &&... args) const
Definition Logger.hpp:121
const char * category() const noexcept
Get category tag.
Definition Logger.hpp:51
void trace(const char *fmt, Args &&... args) const
Definition Logger.hpp:109
void warn(const char *fmt, Args &&... args) const
Definition Logger.hpp:118
void critical(const char *fmt, Args &&... args) const
Definition Logger.hpp:124
LogLevel minLevel() const noexcept
Get minimum log severity level.
Definition Logger.hpp:39
void setMinLevel(LogLevel level) noexcept
Set minimum log severity level.
Definition Logger.hpp:33
void setCategory(const char *category) noexcept
Set category string tag.
Definition Logger.hpp:45
void logToSink(TargetEventSink &&targetSink, LogLevel level, const char *fmt, Args &&... args) const
Post formatted LogEvent to a target Corium EventSink (lock-free MPSC event bus).
Definition Logger.hpp:86
LoggerT(const char *category="App", LogLevel minLevel=LogLevel::Info, LogSink sink=LogSink{})
Definition Logger.hpp:28
void log(LogLevel level, const char *fmt, Args &&... args) const
Log formatted message directly to sink if severity level meets minimum threshold.
Definition Logger.hpp:62
const LogSink & sink() const noexcept
Definition Logger.hpp:58
void info(const char *fmt, Args &&... args) const
Definition Logger.hpp:115
Definition LogBackgroundService.hpp:17
LogLevel
Logging severity levels.
Definition LogLevel.hpp:14
Zero-heap log event carrying fixed-size inline message buffer across MPSC event bus.
Definition LogEvent.hpp:21
LogLevel level
Definition LogEvent.hpp:22