Skip to content

Commit 039b7bc

Browse files
committed
Shorten down debug level constants for better readability
1 parent ac97209 commit 039b7bc

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

Diff for: README.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ This class provides functionality useful for debugging sketches via `printf`-sty
55

66
# How-To-Use Basic
77
ArduinoDebugUtils has 6 different debug levels (described descending from highest to lowest priority):
8-
* `DEBUG_LVL_NONE` - no debug output is shown
9-
* `DEBUG_LVL_ERROR` - critical errors
10-
* `DEBUG_LVL_WARNING` - non-critical errors
11-
* `DEBUG_LVL_INFO` - information
12-
* `DEBUG_LVL_DEBUG` - more information
13-
* `DEBUG_LVL_VERBOSE` - most information
8+
* `DBG_NONE` - no debug output is shown
9+
* `DBG_ERROR` - critical errors
10+
* `DBG_WARNING` - non-critical errors
11+
* `DBG_INFO` - information
12+
* `DBG_DEBUG` - more information
13+
* `DBG_VERBOSE` - most information
1414

15-
The desired debug level can be set via `setDebugLevel(DEBUG_LVL_WARNING)`.
15+
The desired debug level can be set via `setDebugLevel(DBG_WARNING)`.
1616

17-
Debug messages are written via `debugPrint` which supports `printf`-style formatted output.
17+
Debug messages are written via `print` which supports `printf`-style formatted output.
1818

1919
Example:
2020
```C++
2121
int i = 1;
2222
float pi = 3.1459;
23-
Debug.print(DEBUG_LVL_VERBOSE, "i = %d, pi = %f, i, pi);
23+
Debug.print(DBG_VERBOSE, "i = %d, pi = %f, i, pi);
2424
```
2525
2626
If desired timestamps can be prefixed to the debug message. Timestamp output can be enabled and disabled via `timestampOn` and `timestampOff`.

Diff for: examples/Arduino_Debug_Basic/Arduino_Debug_Basic.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ void setup() {
88
int i = 0;
99

1010
void loop() {
11-
Debug.print(DEBUG_LVL_INFO, "i = %d", i);
11+
Debug.print(DBG_INFO, "i = %d", i);
1212
i++;
1313
delay(1000);
1414
}

Diff for: keywords.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ print KEYWORD2
2222
# Constants (LITERAL1)
2323
#######################################
2424

25-
DEBUG_LVL_NONE LITERAL1
26-
DEBUG_LVL_ERROR LITERAL1
27-
DEBUG_LVL_WARNING LITERAL1
28-
DEBUG_LVL_INFO LITERAL1
29-
DEBUG_LVL_DEBUG LITERAL1
30-
DEBUG_LVL_VERBOSE LITERAL1
25+
DBG_NONE LITERAL1
26+
DBG_ERROR LITERAL1
27+
DBG_WARNING LITERAL1
28+
DBG_INFO LITERAL1
29+
DBG_DEBUG LITERAL1
30+
DBG_VERBOSE LITERAL1

Diff for: src/Arduino_DebugUtils.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
CONSTANTS
2626
******************************************************************************/
2727

28-
static int const DEFAULT_DEBUG_LEVEL = DEBUG_LVL_INFO;
28+
static int const DEFAULT_DEBUG_LEVEL = DBG_INFO;
2929
static Stream * DEFAULT_OUTPUT_STREAM = &Serial;
3030

3131
/******************************************************************************
@@ -59,8 +59,8 @@ void Arduino_DebugUtils::timestampOff() {
5959
}
6060

6161
void Arduino_DebugUtils::print(int const debug_level, const char * fmt, ...) {
62-
if (debug_level >= DEBUG_LVL_ERROR &&
63-
debug_level <= DEBUG_LVL_VERBOSE &&
62+
if (debug_level >= DBG_ERROR &&
63+
debug_level <= DBG_VERBOSE &&
6464
debug_level <= _debug_level) {
6565
if (_timestamp_on) {
6666
char timestamp[20];

Diff for: src/Arduino_DebugUtils.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
CONSTANTS
3131
******************************************************************************/
3232

33-
static int const DEBUG_LVL_NONE = -1;
34-
static int const DEBUG_LVL_ERROR = 0;
35-
static int const DEBUG_LVL_WARNING = 1;
36-
static int const DEBUG_LVL_INFO = 2;
37-
static int const DEBUG_LVL_DEBUG = 3;
38-
static int const DEBUG_LVL_VERBOSE = 4;
33+
static int const DBG_NONE = -1;
34+
static int const DBG_ERROR = 0;
35+
static int const DBG_WARNING = 1;
36+
static int const DBG_INFO = 2;
37+
static int const DBG_DEBUG = 3;
38+
static int const DBG_VERBOSE = 4;
3939

4040
/******************************************************************************
4141
CLASS DECLARATION

0 commit comments

Comments
 (0)