summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2013-04-02 09:39:30 (GMT)
committerThomas Graf <tgraf@suug.ch>2013-04-02 09:39:30 (GMT)
commitff567100d6190c9014514f90de522281007c90db (patch)
tree668ef3bf3a7b290fd63ec959c872e25a0593fa95 /include
parentf9241d57fe1fd13aa9ae09d86fe8605451213ef2 (diff)
downloadlibnl-ff567100d6190c9014514f90de522281007c90db.zip
libnl-ff567100d6190c9014514f90de522281007c90db.tar.gz
libnl-ff567100d6190c9014514f90de522281007c90db.tar.bz2
nl: Print file:line:func in debugging messages and provide --disable-debug to disable debugging
Compiling libnl with --disable-debug will result in the ignorance of the 'NLDBG' environment variable. Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'include')
-rw-r--r--include/netlink-private/netlink.h23
1 files changed, 14 insertions, 9 deletions
diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h
index 6ae6d17..2e511bf 100644
--- a/include/netlink-private/netlink.h
+++ b/include/netlink-private/netlink.h
@@ -80,24 +80,29 @@ struct trans_list {
struct nl_list_head list;
};
-#define NL_DEBUG 1
-
-#define NL_DBG(LVL,FMT,ARG...) \
- do { \
- if (LVL <= nl_debug) \
- fprintf(stderr, "DBG<" #LVL ">: " FMT, ##ARG); \
+#ifdef NL_DEBUG
+#define NL_DBG(LVL,FMT,ARG...) \
+ do { \
+ if (LVL <= nl_debug) \
+ fprintf(stderr, \
+ "DBG<" #LVL ">%20s:%-4u %s: " FMT, \
+ __FILE__, __LINE__, \
+ __PRETTY_FUNCTION__, ##ARG); \
} while (0)
+#else /* NL_DEBUG */
+#define NL_DBG(LVL,FMT,ARG...) do { } while(0)
+#endif /* NL_DEBUG */
#define BUG() \
do { \
- NL_DBG(1, "BUG: %s:%d\n", \
- __FILE__, __LINE__); \
+ fprintf(stderr, "BUG at file position %s:%d:%s\n", \
+ __FILE__, __LINE__, __PRETTY_FUNCTION__); \
assert(0); \
} while (0)
#define APPBUG(msg) \
do { \
- NL_DBG(1, "APPLICATION BUG: %s:%d:%s: %s\n", \
+ fprintf(stderr, "APPLICATION BUG: %s:%d:%s: %s\n", \
__FILE__, __LINE__, __PRETTY_FUNCTION__, msg); \
assert(0); \
} while(0)