14#ifndef SBL_LOG_LOGGER_HPP_
15#define SBL_LOG_LOGGER_HPP_
55 static uint32_t
now() {
return 0; }
62 static void write(
const char*) {}
70constexpr const char*
basename(
const char* path) {
71 const char* file = path;
73 if (*path ==
'/' || *path ==
'\\') {
88template<
typename Output,
typename TimestampProv
ider = NullTimestamp, Level MinLevel = Level::Info>
102 static void log(
Level level,
const char* file,
int line,
const char* fmt, ...) {
104 if (
static_cast<int>(level) >
static_cast<int>(MinLevel)) {
112 uint32_t timestamp = TimestampProvider::now();
130 buffer[pos++] =
'\n';
135 Output::write(buffer);
144 if (
static_cast<int>(level) >
static_cast<int>(MinLevel)) {
151 uint32_t timestamp = TimestampProvider::now();
165 buffer[pos++] =
'\n';
169 Output::write(buffer);
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 constexpr size_t BUFFER_SIZE
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.
Null output sink (discards all output)
static void write(const char *)
Default timestamp provider (returns 0)