DebugUtils 1.0.0
Cross-platform logging macros for Arduino and native tests
Loading...
Searching...
No Matches
DebugUtils

Doxygen

API docs: https://crabel99.github.io/DebugUtils/

DebugUtils provides lightweight logging macros that work across:

  • Embedded Arduino builds (Serial by default)
  • Embedded debug builds (SerialRTT when _DEBUG_ is defined)
  • Native unit tests (stdout when NATIVE_TEST is defined)

Features

  • Unified LOG_* levels and convenience macros (_PL, _PLD, _PPE, etc.)
  • Build-time log filtering via LOG_LEVEL
  • Same source code for hardware and native test logging

Quick Start

#define _DEBUG_
#define LOG_LEVEL LOG_DEBUG
#include <debug.h>
void setup() {
SERIAL_PORT.begin();
_PL("DebugUtils initialized");
_PLD("Verbose logging enabled");
}
void loop() {
_PL("heartbeat");
delay(1000);
}
Cross-platform logging and serial output for Arduino and native tests.
#define SERIAL_PORT
Active serial backend used by logging macros (Arduino Serial by default).
Definition debug.h:223
#define _PLD(...)
Print debug level output with newline.
Definition debug.h:298
#define _PL(...)
Print info level output with newline.
Definition debug.h:296

Dependencies

When _DEBUG_ is defined on embedded targets, DebugUtils routes output to SerialRTT. In PlatformIO, add it as a dependency:

lib_deps =
https://github.com/crabel99/SerialRTT.git

Log Levels

  • LOG_ERROR
  • LOG_WARN
  • LOG_INFO (default)
  • LOG_DEBUG

Set in your project:

#define LOG_LEVEL LOG_DEBUG
#include <debug.h>

Native Tests

Define NATIVE_TEST before including debug.h to route logging macros to stdout for host-based tests:

#define NATIVE_TEST
#include <debug.h>
void test_fn() {
_PL("Native log -> stdout");
}

License

MIT. See LICENSE.