diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index d30277a0..362b1609 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -24,6 +24,8 @@ jobs: - name: Arduino_ConnectionHandler - name: ArduinoHttpClient - name: Arduino_DebugUtils + - source-url: https://github.com/arduino-libraries/Arduino_DebugUtils.git + version: logging-improvements - name: ArduinoMqttClient - name: Arduino_SecureElement - name: Arduino_CloudUtils diff --git a/src/AIoTC_Config.h b/src/AIoTC_Config.h index a25b8108..5a2a63fc 100644 --- a/src/AIoTC_Config.h +++ b/src/AIoTC_Config.h @@ -34,24 +34,22 @@ #define NTP_USE_RANDOM_PORT (1) #endif -#ifndef DEBUG_ERROR - #define DEBUG_ERROR(fmt, ...) Debug.print(DBG_ERROR, fmt, ## __VA_ARGS__) -#endif - -#ifndef DEBUG_WARNING - #define DEBUG_WARNING(fmt, ...) Debug.print(DBG_WARNING, fmt, ## __VA_ARGS__) -#endif - -#ifndef DEBUG_INFO - #define DEBUG_INFO(fmt, ...) Debug.print(DBG_INFO, fmt, ## __VA_ARGS__) -#endif +// include directives must be ordered in such a way that this always comes first, +// otherwise the log level will be incorrectly set +#ifndef DEBUG_LEVEL + #define DEBUG_LEVEL DEBUG_LEVEL_INFO +#endif // DEBUG_LEVEL -#ifndef DEBUG_DEBUG - #define DEBUG_DEBUG(fmt, ...) Debug.print(DBG_DEBUG, fmt, ## __VA_ARGS__) -#endif - -#ifndef DEBUG_VERBOSE - #define DEBUG_VERBOSE(fmt, ...) //Debug.print(DBG_VERBOSE, fmt, ## __VA_ARGS__) +#if defined __has_include + #if !__has_include () + #define DEBUG_ERROR (void) 0 + #define DEBUG_WARNING (void) 0 + #define DEBUG_INFO (void) 0 + #define DEBUG_DEBUG (void) 0 + #define DEBUG_VERBOSE (void) 0 + #elif defined(__cplusplus) + #include + #endif #endif /******************************************************************************