A lightweight and efficient logging library designed for microcontrollers such as Arduino, ESP32, and similar devices. Logger simplifies debugging and monitoring by providing structured log output, tailored specifically for embedded systems.
Compatible with PlatformIO, this library is easy to integrate and optimized for resource-constrained devices.
- Log Levels: Supports five essential levels:
Debug
,Info
,Warn
,Error
, andCritical
. - PlatformIO Compatible: Seamlessly integrates into PlatformIO-based projects.
- Low Resource Usage: Designed for minimal memory and CPU overhead.
- No Custom Log Levels: Only supports pre-defined levels (
Debug
,Info
,Warn
,Error
,Critical
). - No Persistent Storage: Logs are currently not saved to non-volatile memory or external storage.
- Not Extensible: The library does not support plugins or additional features at this time.
Clone or download the repository and integrate it with your PlatformIO project:
- Copy the
Logger
library folder into your project'slib
directory. - Include the library in your code.
#include <Arduino.h>
#include <Logger.h>
Logger logger(Debug, "[{time}] {level} [{file}.{function}.{lineno}] {message}"); // Create a logger instance with log level Info
void setup()
{
Serial.begin(115200);
Serial.println("\n");
LOG(Debug, "This is a debug message");
LOG(Info, "This is the number %d: %d", 3, 3);
LOG(Warning, "Countdown: %d, %d, %d", 3, 2, 1);
LOG(Error, "Error encountered: %s", "Value invalid");
LOG(Critical, "This is a critical message");
}
The library supports the following log levels:
- Debug: Detailed information for debugging.
- Info: General system information.
- Warn: Warnings for potential issues.
- Error: Errors requiring immediate attention.
- Critical: Severe issues affecting system stability.
Customize the logger when initializing:
Logger logger({Log Level}, {Log Format}); // Enable timestamps in the Serial output
Configuration Options:
- Log Level: Set the minimum log level to display (e.g.,
Debug
,Info
,Warn
,Error
,Critical
). - Log Format: Define the format for log messages, including placeholders for timestamp, log level, file, function, line number, and message.
-
Persistent Logs
: Add support for saving logs to SD cards or EEPROM. -
Multi-Interface Support
: Enable logging over UART, I2C, or SPI.
Contributions are welcome! Here's how you can help:
- 📋 Contribute to the Project: Review the contribution guidelines and consider submitting a pull request.
- 🐛 Report Issues: Submit bugs found or log feature requests for the project.
- 💡 Submit Pull Requests: Review open PRs, and submit your own PRs.
This project is protected under the MIT License. For more details, refer to the LICENSE file.
Developed by Marcos Helbert.
Feel free to open issues or share suggestions for improving the library!