aboutsummaryrefslogtreecommitdiffstats
path: root/src/dbg.h
diff options
context:
space:
mode:
authorTharre <tharre3@gmail.com>2016-10-27 23:43:45 +0200
committerTharre <tharre3@gmail.com>2016-10-27 23:50:45 +0200
commit15465e8b518d9413c11dcdcad712a6a51b3ebde2 (patch)
treef6fed48f65879e2d6be70fd602e2e61062a1ccb2 /src/dbg.h
parentd0b51f93d00c600d2c2e5480b1fd1d8d32bb1fdc (diff)
downloadredo-15465e8b518d9413c11dcdcad712a6a51b3ebde2.tar.gz
redo-15465e8b518d9413c11dcdcad712a6a51b3ebde2.tar.xz
redo-15465e8b518d9413c11dcdcad712a6a51b3ebde2.zip
Implement logging using REDO_DEBUG env variable
Diffstat (limited to 'src/dbg.h')
-rw-r--r--src/dbg.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/dbg.h b/src/dbg.h
index 902d885..6e52ed4 100644
--- a/src/dbg.h
+++ b/src/dbg.h
@@ -25,12 +25,16 @@
#define DEBUG 0
#endif
+extern int DBG_LVL;
+
/* helper functions which help in replacing the GNU extension ##__VA_ARGS__ */
#define STRINGIFY(x) #x
#define PREFIX(...) PREFIX_HELPER(_FILENAME, __LINE__, __VA_ARGS__)
#define SUFFIX(S, M, ...) M S, __VA_ARGS__
#define log_err(...) fprintf(stderr, PREFIX(__VA_ARGS__))
+#define log_warn(...) do { if (DBG_LVL > 2) log_err(__VA_ARGS__); } while (0)
+#define log_info(...) do { if (DBG_LVL > 1) log_err(__VA_ARGS__); } while (0)
#define die(...) die_(PREFIX(__VA_ARGS__))
#define fatal(...) die(SUFFIX(": %s\n", __VA_ARGS__, strerror(errno)))