7 * Debug logging macros. Define DEBUG_LOG or DEBUG_LOG_VERBOSE to enable logging,
8 * verbose adds overwhelming detail. All macros start with DBG or DBGV (for verbose)
9 * DBGCR / DBGVCR - Print newline (Serial.println())
10 * DBG / DBGV - Print messag with optional format specifier (Serial.printf(x, ...))
11 * DBGLN / DBGVLN - Same as DBG except also includes newline
12 * DBGW / DBGVW - Write a single byte to logging (Serial.write(x))
14 * Set LOGGING_UART define to Serial instance to use if not Serial
17 // DEBUG_LOG_VERBOSE and DEBUG_RX_SCOREBOARD implies DEBUG_LOG
18 #if !defined(DEBUG_LOG)
19 #if defined(DEBUG_LOG_VERBOSE) || (defined(DEBUG_RX_SCOREBOARD) && TARGET_RX) || defined(DEBUG_INIT)
24 #if defined(TARGET_RX) && (defined(DEBUG_RCVR_LINKSTATS) || defined(DEBUG_RX_SCOREBOARD) || defined(DEBUG_RCVR_SIGNAL_STATS)) || defined(DEBUG_LOG)
28 #if defined(TARGET_TX)
29 extern Stream
*TxBackpack
;
30 #if defined(PLATFORM_ESP32_S3)
31 #define LOGGING_UART (Serial)
33 #define LOGGING_UART (*TxBackpack)
36 extern Stream
*SerialLogger
;
37 #define LOGGING_UART (*SerialLogger)
40 // #define LOG_USE_PROGMEM
42 void debugPrintf(const char* fmt
, ...);
44 void debugCreateInitLogger();
45 void debugFreeInitLogger();
47 #define debugCreateInitLogger()
48 #define debugFreeInitLogger()
51 #if defined(CRITICAL_FLASH) || ((defined(DEBUG_RCVR_LINKSTATS)) && !defined(DEBUG_LOG))
52 #define ERRLN(msg, ...)
54 #define ERRLN(msg, ...) IFNE(__VA_ARGS__)({ \
55 LOGGING_UART.print("ERROR: "); \
56 debugPrintf(msg, ##__VA_ARGS__); \
57 LOGGING_UART.println(); \
58 },LOGGING_UART.println("ERROR: " msg))
61 #if defined(DEBUG_LOG) && !defined(CRITICAL_FLASH)
62 #define DBGCR LOGGING_UART.println()
63 #define DBGW(c) LOGGING_UART.write(c)
64 #ifndef LOG_USE_PROGMEM
65 #define DBG(msg, ...) debugPrintf(msg, ##__VA_ARGS__)
66 #define DBGLN(msg, ...) do { \
67 debugPrintf(msg, ##__VA_ARGS__); \
68 LOGGING_UART.println(); \
71 #define DBG(msg, ...) debugPrintf(PSTR(msg), ##__VA_ARGS__)
72 #define DBGLN(msg, ...) { \
73 debugPrintf(PSTR(msg), ##__VA_ARGS__); \
74 LOGGING_UART.println(); \
78 // Verbose logging is for spammy stuff
79 #if defined(DEBUG_LOG_VERBOSE)
81 #define DBGVW(c) DBGW(c)
82 #define DBGV(...) DBG(__VA_ARGS__)
83 #define DBGVLN(...) DBGLN(__VA_ARGS__)