]> git.itanic.dy.fi Git - glucose/blobdiff - utils.h
Make excess debug messages to be hidden by default
[glucose] / utils.h
diff --git a/utils.h b/utils.h
index a0bdfb5094a15c697ef1963a6d16bc12a013a40a..e84ef3609e301852da32e454045c0e1875bed16d 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -1,6 +1,8 @@
 #ifndef _UTILS_H
 #define _UTILS_H
 
+#include <stdio.h>
+
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 static inline int is_printable(const unsigned char c)
@@ -8,6 +10,14 @@ static inline int is_printable(const unsigned char c)
        return c >= 0x20 && c < 0x80;
 }
 
+extern int trace_level;
+
+#define trace(level, arg...)                   \
+       do {                                    \
+               if (level <= trace_level)       \
+                       printf(arg);            \
+       } while (0)
+
 int datalen(const unsigned char *data);
 void print_hex(const unsigned char *data, int len);
 void print_ascii(const unsigned char *data, int len);