This class provides functionality useful for debugging sketches via printf
-style statements.
ArduinoDebugUtils has 6 different debug levels (described descending from highest to lowest priority):
DEBUG_LVL_NONE
- no debug output is shownDEBUG_LVL_ERROR
- critical errorsDEBUG_LVL_WARNING
- non-critical errorsDEBUG_LVL_INFO
- informationDEBUG_LVL_DEBUG
- more informationDEBUG_LVL_VERBOSE
- most information
The desired debug level can be set via setDebugLevel(DebugLevel::Warning)
.
Debug messages are written via debugPrint
which supports printf
-style formatted output.
Example:
int i = 1;
float pi = 3.1459;
ArduinoDebugUtils.debugPrint(DEBUG_LVL_VERBOSE, "i = %d, pi = %f, i, pi);
If desired timestamps can be prefixed to the debug message. Timestamp output can be enabled and disabled via timestampOn
and timestampOff
.
Normally all debug output is redirected to the primary serial output of each board (Serial
). In case you want to redirect the output to another output stream you can make use of setDebugOutputStream(&Serial2)
.