]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[DEBUG] add a TRACE macro to facilitate runtime data extraction
authorWilly Tarreau <w@1wt.eu>
Fri, 13 Jun 2008 20:36:31 +0000 (22:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 20 Jun 2008 13:05:52 +0000 (15:05 +0200)
The new TRACE macro is used almost like fprintf, except that a session
has to be passed  instead of the file descriptor. It displays infos about
where it is called, session ptr and id, etc...

include/common/debug.h

index 1e529853f3179efda572aa91ba78f757303d0665..cbd752ef6fc24d618f24d262143f18c8a60a93f8 100644 (file)
 #define FSM_PRINTF(x...)
 #endif
 
+/* this one is provided for easy code tracing.
+ * Usage: TRACE(sess||0, fmt, args...);
+ *        TRACE(sess, "");
+ */
+#define TRACE(sess, fmt, args...) do {                            \
+       fprintf(stderr,                                           \
+               "%d.%06d [%s:%d %s] [sess %p(%x)] " fmt "\n",      \
+               (int)now.tv_sec, (int)now.tv_usec,                \
+               __FILE__, __LINE__, __FUNCTION__,                 \
+               sess, sess?((struct session *)sess)->uniq_id:~0U, \
+               ##args);                                           \
+        } while (0)
+
+
 #endif /* _COMMON_DEBUG_H */