14#ifndef SBL_COMMON_LOG_LOGGER_HPP_
15#define SBL_COMMON_LOG_LOGGER_HPP_
41 case Level::Error:
return 'E';
42 case Level::Warn:
return 'W';
43 case Level::Info:
return 'I';
44 case Level::Debug:
return 'D';
45 case Level::Trace:
return 'T';
55constexpr const char*
basename(
const char* path) {
56 const char* file = path;
58 if (*path ==
'/' || *path ==
'\\') {
73template<
typename Output,
typename TimestampProv
ider = NullTimestamp, Level MinLevel = Level::Info>
76 "Required: static void write(const char* str)");
78 "Required: static uint32_t now()");
81 static constexpr size_t BUFFER_SIZE = 256;
94 if (
static_cast<int>(level) >
static_cast<int>(
MinLevel)) {
106 if (
pos < BUFFER_SIZE - 1) {
114 if (
pos < BUFFER_SIZE - 1) {
129 if (
static_cast<int>(level) >
static_cast<int>(
MinLevel)) {
139 if (
pos < BUFFER_SIZE - 1) {
146 if (
pos < BUFFER_SIZE - 1) {
Logger class with compile-time level filtering.
static void log(Level level, const char *file, int line, const char *fmt,...)
Log a message with file/line location.
static void log_simple(Level level, const char *fmt,...)
Log without location info (simpler format)
constexpr char level_char(Level level)
Convert level to single character.
constexpr const char * basename(const char *path)
Extract filename from path (compile-time safe)
int vformat(char *buf, size_t size, const char *fmt, va_list args)
Format a string into a buffer (vsnprintf-style)
int format(char *buf, size_t size, const char *fmt,...)
Format a string into a buffer (snprintf-style)
Level
Log severity levels.
The logger's two contracts: an output sink and a timestamp provider.