64 printf(
"[%s] [%s] %s\n", timeBuf, levelStr, msg);
71 snprintf(fullMsg,
sizeof(fullMsg),
"[%s] [%s] %s\n", timeBuf, levelStr, msg);
72 storage->appendToFile(
logPath,
reinterpret_cast<const uint8_t*
>(fullMsg), strlen(fullMsg));
82 struct tm *t = gmtime(&now);
83 strftime(buffer, len,
"%Y-%m-%dT%H:%M:%SZ", t);
103 if (
logPath.empty())
return false;
106 auto reader = storage->openReader(
logPath);
107 if (!reader)
return false;
110 while (reader->readLine(line,
sizeof(line))) {
Lightweight structured logging class for embedded applications.
LogLevel
Severity levels for logging.
@ LOG_ERROR
Errors (potentially requiring user action)
@ LOG_INFO
Informational messages.
@ LOG_WARN
Warnings (non-fatal)
Time utility functions for the Pico platform (RP2040/RP2350).
static constexpr std::uintptr_t getTypeKey()
static void getTimeString(char *buffer, size_t len)
static bool forEachLine(const std::function< void(const char *line)> &handler)
Streams each line of the log file to the provided handler.
static const char * levelToString(LogLevel level)
static void info(const char *msg)
Log an informational message.
static void error(const char *msg)
Log an error message.
static void setMinLogLevel(LogLevel level)
Set the minimum log level (filters lower levels).
static void enableFileLogging(const std::string &path)
Enable writing logs to SD card via a storage manager.
static void warn(const char *msg)
Log a warning message.
static std::string logPath
static void log(LogLevel level, const char *msg)
static time_t now()
Get the current epoch time using platform RTC or AON.