Skip to content

Commit 5e5387c

Browse files
Adding an example to show debug level usage
1 parent daa33a0 commit 5e5387c

File tree

3 files changed

+30
-7
lines changed

3 files changed

+30
-7
lines changed
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#define DEBUG_LEVEL DEBUG_LEVEL_INFO
2+
#include <Arduino_DebugUtils.h>
3+
4+
void setup() {
5+
Serial.begin(9600);
6+
Debug.timestampOn();
7+
Debug.debugLabelOn();
8+
Debug.setDebugLevel(DBG_ALL);
9+
}
10+
11+
int i = 0;
12+
13+
void loop() {
14+
DEBUG_ERROR("i = %d", i);
15+
DEBUG_WARNING("i = %d", i);
16+
DEBUG_INFO("i = %d", i);
17+
DEBUG_DEBUG("i = %d", i);
18+
DEBUG_VERBOSE("i = %d", i);
19+
20+
Serial.println();
21+
i++;
22+
delay(1000);
23+
}

Diff for: src/Arduino_DebugUtils.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,10 @@ bool Arduino_DebugUtils::shouldPrint(Arduino_DebugUtils::Level const debug_level
249249

250250
Arduino_DebugUtils Debug;
251251

252-
void setDebugMessageLevel(int const debug_level) {
253-
Debug.setDebugLevel(static_cast<Arduino_DebugUtils::Level>(debug_level));
252+
void setDebugMessageLevel(Arduino_DebugUtils::Level const debug_level) {
253+
Debug.setDebugLevel(debug_level);
254254
}
255255

256-
int getDebugMessageLevel() {
257-
return static_cast<int>(Debug.getDebugLevel());
256+
Arduino_DebugUtils::Level getDebugMessageLevel() {
257+
return Debug.getDebugLevel();
258258
}

Diff for: src/Arduino_DebugUtils.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
#include <stdarg.h>
2828

29-
void setDebugMessageLevel(int const debug_level);
30-
int getDebugMessageLevel();
31-
3229
#define DEBUG_LEVEL_NONE 0x0000
3330
#define DEBUG_LEVEL_ERROR 0x0001
3431
#define DEBUG_LEVEL_WARNING 0x0003
@@ -93,6 +90,9 @@ class Arduino_DebugUtils {
9390

9491
};
9592

93+
void setDebugMessageLevel(Arduino_DebugUtils::Level const debug_level);
94+
Arduino_DebugUtils::Level getDebugMessageLevel();
95+
9696
/******************************************************************************
9797
CONSTANTS
9898
******************************************************************************/

0 commit comments

Comments
 (0)