Paul Cercueil / libiio

Dependencies:   libserialport libxml2

Revision:
2:9eb0a9a1f958
Parent:
0:df031b60ca29
Child:
4:ad69b39bf124
--- a/debug.h	Thu Aug 25 16:01:01 2016 +0000
+++ b/debug.h	Tue Sep 20 15:34:31 2016 +0000
@@ -19,17 +19,15 @@
 #ifndef DEBUG_H
 #define DEBUG_H
 
+#include "iio-config.h"
+
 #include <stdio.h>
 
-#define NODEBUG_L 0
-#define ERROR_L 1
-#define WARNING_L 2
-#define INFO_L 3
-#define DEBUG_L 4
-
-#ifndef LOG_LEVEL
-#define LOG_LEVEL INFO_L
-#endif
+#define NoLog_L 0
+#define Error_L 1
+#define Warning_L 2
+#define Info_L 3
+#define Debug_L 4
 
 /* -------------------- */
 
@@ -47,7 +45,7 @@
 #define COLOR_END "\e[0m"
 #endif
 
-#if (LOG_LEVEL >= DEBUG_L)
+#if (LOG_LEVEL >= Debug_L)
 # ifdef COLOR_DEBUG
 #  define DEBUG(str, ...) \
     fprintf(stdout, COLOR_DEBUG "DEBUG: " str COLOR_END, ##__VA_ARGS__)
@@ -56,10 +54,10 @@
     fprintf(stdout, "DEBUG: " __VA_ARGS__)
 # endif
 #else
-#define DEBUG(...)
+#define DEBUG(...) do { } while (0)
 #endif
 
-#if (LOG_LEVEL >= INFO_L)
+#if (LOG_LEVEL >= Info_L)
 # ifdef COLOR_INFO
 #  define INFO(str, ...) \
     fprintf(stdout, COLOR_INFO str COLOR_END, ##__VA_ARGS__)
@@ -68,10 +66,10 @@
     fprintf(stdout, __VA_ARGS__)
 # endif
 #else
-#define INFO(...)
+#define INFO(...) do { } while (0)
 #endif
 
-#if (LOG_LEVEL >= WARNING_L)
+#if (LOG_LEVEL >= Warning_L)
 # ifdef COLOR_WARNING
 #  define WARNING(str, ...) \
     fprintf(stderr, COLOR_WARNING "WARNING: " str COLOR_END, ##__VA_ARGS__)
@@ -80,10 +78,10 @@
     fprintf(stderr, "WARNING: " __VA_ARGS__)
 # endif
 #else
-#define WARNING(...)
+#define WARNING(...) do { } while (0)
 #endif
 
-#if (LOG_LEVEL >= ERROR_L)
+#if (LOG_LEVEL >= Error_L)
 # ifdef COLOR_ERROR
 #  define ERROR(str, ...) \
     fprintf(stderr, COLOR_ERROR "ERROR: " str COLOR_END, ##__VA_ARGS__)
@@ -92,7 +90,7 @@
     fprintf(stderr, "ERROR: " __VA_ARGS__)
 # endif
 #else
-#define ERROR(...)
+#define ERROR(...) do { } while (0)
 #endif
 
 #endif