Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
Logger.h File Reference

Lightweight structured logging class for embedded applications. More...

#include <cstdio>
#include <ctime>
#include <string>
#include "storage/StorageManager.h"
+ Include dependency graph for Logger.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Logger
 Basic timestamped logger with optional SD file logging. More...
 

Enumerations

enum  LogLevel { LOG_INFO , LOG_WARN , LOG_ERROR }
 Severity levels for logging. More...
 

Detailed Description

Author
Ian Archbell

Part of the PicoFramework application framework. Logs messages with timestamps and severity levels (INFO, WARN, ERROR). Optionally supports logging to an SD card via FatFsStorageManager.

Usage example:

Logger::setMinLogLevel(LOG_INFO); // Set minimum log level to INFO
Logger::enableFileLogging(AppContext::storage(), "/log/system.log");
Logger::info("System started successfully.");
Logger::warn("Low battery warning.");
Logger::error("Critical error occurred.");
@ LOG_INFO
Informational messages.
Definition Logger.h:38
static void info(const char *msg)
Log an informational message.
Definition Logger.cpp:23
static void error(const char *msg)
Log an error message.
Definition Logger.cpp:35
static void setMinLogLevel(LogLevel level)
Set the minimum log level (filters lower levels).
Definition Logger.cpp:41
static void enableFileLogging(const std::string &path)
Enable writing logs to SD card via a storage manager.
Definition Logger.cpp:47
static void warn(const char *msg)
Log a warning message.
Definition Logger.cpp:29
Version
0.2
Date
2025-03-31
License:\n MIT License

Definition in file Logger.h.

Enumeration Type Documentation

◆ LogLevel

enum LogLevel
Enumerator
LOG_INFO 

Informational messages.

LOG_WARN 

Warnings (non-fatal)

LOG_ERROR 

Errors (potentially requiring user action)

Definition at line 37 of file Logger.h.

37 {
38 LOG_INFO,
39 LOG_WARN,
41 };
@ LOG_ERROR
Errors (potentially requiring user action)
Definition Logger.h:40
@ LOG_WARN
Warnings (non-fatal)
Definition Logger.h:39