Skip to content

Commit 585549e

Browse files
Making use of DEBUG_LEVEL macros
in this way we are able to select the debug level that needs to be included in the sketch at compile time. The default value is to include all the possible logs
1 parent 8da4fc0 commit 585549e

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

Diff for: src/Arduino_DebugUtils.h

+25-10
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,39 @@ extern Arduino_DebugUtils Debug;
106106
* DEFINE
107107
**************************************************************************************/
108108

109-
#ifndef DEBUG_ERROR
110-
# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
109+
110+
#ifndef DEBUG_LEVEL
111+
# define DEBUG_LEVEL DEBUG_LEVEL_ALL
112+
#endif
113+
114+
#if !defined(DEBUG_ERROR) && ((DEBUG_LEVEL & DEBUG_LEVEL_ERROR) == DEBUG_LEVEL_ERROR)
115+
# define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__)
116+
#else
117+
# define DEBUG_ERROR(fmt, ...) (void) 0
111118
#endif
112119

113-
#ifndef DEBUG_WARNING
114-
# define DEBUG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__)
120+
#if !defined(DEBUG_WARNING) && ((DEBUG_LEVEL & DEBUG_LEVEL_WARNING) == DEBUG_LEVEL_WARNING)
121+
# define DEBUG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__)
122+
#else
123+
# define DEBUG_WARNING(fmt, ...) (void) 0
115124
#endif
116125

117-
#ifndef DEBUG_INFO
118-
# define DEBUG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__)
126+
#if !defined(DEBUG_INFO) && ((DEBUG_LEVEL & DEBUG_LEVEL_INFO) == DEBUG_LEVEL_INFO)
127+
# define DEBUG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__)
128+
#else
129+
# define DEBUG_INFO(fmt, ...) (void) 0
119130
#endif
120131

121-
#ifndef DEBUG_DEBUG
122-
# define DEBUG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__)
132+
#if !defined(DEBUG_DEBUG) && ((DEBUG_LEVEL & DEBUG_LEVEL_DEBUG) == DEBUG_LEVEL_DEBUG)
133+
# define DEBUG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__)
134+
#else
135+
# define DEBUG_DEBUG(fmt, ...) (void) 0
123136
#endif
124137

125-
#ifndef DEBUG_VERBOSE
126-
# define DEBUG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
138+
#if !defined(DEBUG_VERBOSE) && ((DEBUG_LEVEL & DEBUG_LEVEL_VERBOSE) == DEBUG_LEVEL_VERBOSE)
139+
# define DEBUG_VERBOSE(fmt, ...) Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__)
140+
#else
141+
# define DEBUG_VERBOSE(fmt, ...) (void) 0
127142
#endif
128143

129144
#endif /* ARDUINO_DEBUG_UTILS_H_ */

0 commit comments

Comments
 (0)