Modified: 2021-06
Macro Logger is an arduino logging library with support for precompilation directives and printf
formatting. This library is adapted from Christopher Baker's Logger library.
Install the library from the arduino-cli package manager:
arduino-cli lib install MacroLogger
Below is a snippet of the basic usage:
#include <Logger.h>
void setup() {
Serial.begin(9600);
Logger::set_level(Logger::Level::WARNING);
}
void loop() {
Logger::critical("This is a critical logging message");
Logger::error("This is a error logging message");
Logger::warning("This is a warning logging message");
Logger::info("This is an info logging message: %d", 5);
Logger::trace("This is a trace logging message: %s", "");
delay(500);
}
Serial monitor output:
[CRITICAL] loop:25 This is a critical logging message
[ERROR] loop:25 This is a error logging message
[WARNING] loop:25 This is a warning logging message
[INFO] loop:25 This is an info logging message: 5
[TRACE] loop:25 This is a trace logging message: