From db703b19181a093e54e8619ae7c4aeac07dd8daf Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 4 Nov 2019 11:40:10 +0100 Subject: [PATCH] MINOR: trace: Add a set of macros to trace events if HA is compiled with debug The macros DBG_TRACE_*() can be used instead of existing trace macros to emit trace messages in debug mode only, ie, when HAProxy is compiled with DEBUG_FULL or DEBUG_DEV. Otherwise, these macros do nothing. So it is possible to add traces for development purpose without impacting performance of production instances. --- include/proto/trace.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/proto/trace.h b/include/proto/trace.h index 4ef13078c..ece23293b 100644 --- a/include/proto/trace.h +++ b/include/proto/trace.h @@ -77,6 +77,28 @@ #define TRACE_POINT(mask, ...) \ trace(TRACE_LEVEL_DEVELOPER, (mask), TRACE_SOURCE, ist(TRC_LOC), __FUNCTION__, TRC_5ARGS(__VA_ARGS__,,,,,), ist("in")) +#if defined(DEBUG_DEV) || defined(DEBUG_FULL) +# define DBG_TRACE(msg, mask, ...) TRACE(msg, mask, __VA_ARGS__) +# define DBG_TRACE_USER(msg, mask, ...) TRACE_USER(msg, mask, __VA_ARGS__) +# define DBG_TRACE_DATA(msg, mask, ...) TRACE_DATA(msg, mask, __VA_ARGS__) +# define DBG_TRACE_PROTO(msg, mask, ...) TRACE_PROTO(msg, mask, __VA_ARGS__) +# define DBG_TRACE_STATE(msg, mask, ...) TRACE_STATE(msg, mask, __VA_ARGS__) +# define DBG_TRACE_DEVEL(msg, mask, ...) TRACE_DEVEL(msg, mask, __VA_ARGS__) +# define DBG_TRACE_ENTER(mask, ...) TRACE_ENTER(mask, __VA_ARGS__) +# define DBG_TRACE_LEAVE(mask, ...) TRACE_LEAVE(mask, __VA_ARGS__) +# define DBG_TRACE_POINT(mask, ...) TRACE_POINT(mask, __VA_ARGS__) +#else +# define DBG_TRACE(msg, mask, ...) do { /* do nothing */ } while(0) +# define DBG_TRACE_USER(msg, mask, ...) do { /* do nothing */ } while(0) +# define DBG_TRACE_DATA(msg, mask, ...) do { /* do nothing */ } while(0) +# define DBG_TRACE_PROTO(msg, mask, ...) do { /* do nothing */ } while(0) +# define DBG_TRACE_STATE(msg, mask, ...) do { /* do nothing */ } while(0) +# define DBG_TRACE_DEVEL(msg, mask, ...) do { /* do nothing */ } while(0) +# define DBG_TRACE_ENTER(mask, ...) do { /* do nothing */ } while(0) +# define DBG_TRACE_LEAVE(mask, ...) do { /* do nothing */ } while(0) +# define DBG_TRACE_POINT(mask, ...) do { /* do nothing */ } while(0) +#endif + extern struct list trace_sources; extern THREAD_LOCAL struct buffer trace_buf;