Skip to content

Instantly share code, notes, and snippets.

@xidameng
Created September 15, 2021 10:24
Show Gist options
  • Save xidameng/a433436921e0325426ea71303afc8dde to your computer and use it in GitHub Desktop.
Save xidameng/a433436921e0325426ea71303afc8dde to your computer and use it in GitHub Desktop.
// Comment the following line to disable DEBUG log
#define __DEBUG__
#ifdef __DEBUG__
// You should only uncomment 1 version at a time!
// Version 1
//#define DEBUG(...) Serial.println(__VA_ARGS__)
// Version 2
#define DEBUG(...) Serial.println(__VA_ARGS__); \
Serial.print(" @ [SRC]: "); \
Serial.println(__FILE__); \
Serial.print(" @ [LINE]: "); \
Serial.println(__LINE__); \
Serial.print(" @ [FUNCTION]: "); \
Serial.println(__func__);
#else
// else DEBUG is diabled
#define DEBUG(...)
#endif
void setup() {
Serial.begin(115200);
DEBUG("--Debug starts--");
}
void loop() {
DEBUG("++Debug #1++");
delay(1000);
DEBUG("==Debug #2==");
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment