Logger
Singleton logging system with color output, ASCII art, and per-tag filtering.
Access
1
2
| auto& logger = Logger::GetInstance();
logger.Initialize(); // Optional config: Logger::GetInstance().Initialize(config);
|
Log Methods
1
2
3
4
5
| logger.Error("MyTag", "Error: code %d", err);
logger.Warn("MyTag", "Warning: value %.2f", val);
logger.Info("MyTag", "Info: initialized");
logger.Debug("MyTag", "Debug: state=%d", state);
logger.Verbose("MyTag", "Verbose: raw=0x%04X", raw);
|
1
2
| logger.Info("Tag", LogColor::GREEN, LogStyle::BOLD,
"Bold green: %d", value);
|
ASCII Art
1
2
3
4
5
| logger.LogBanner("Tag", R"(
_ _ _____ _____ _____
| | | | ___| _ | _ |
| |_| | |__ | | | | |_| |
)");
|
Per-Tag Filtering
1
| logger.SetLogLevel("NoisyModule", LogLevel::WARN); // Only WARN+ for this tag
|
Convenience Macros
1
2
3
4
5
| LOG_ERROR("tag", "message %d", val);
LOG_WARN("tag", "message");
LOG_INFO("tag", "message");
LOG_DEBUG("tag", "message");
LOG_VERBOSE("tag", "message");
|
Thread Safety
The Logger is thread-safe and can be called from any RTOS task or ISR context
(for short messages).
Test Coverage
See examples/esp32/main/utils_tests/logger_comprehensive_test.cpp.