From 71d316dfc51bcb9e18da61fb7299bb021523cde4 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Tue, 10 Nov 2015 22:59:05 -0500 Subject: Add options to specify a debug level Print only messages that are at that level or lower. Also add timestamps to debug messages. Signed-off-by: Simo Sorce Reviewed-by: Robbie Harwood --- proxy/src/gp_debug.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'proxy/src/gp_debug.h') diff --git a/proxy/src/gp_debug.h b/proxy/src/gp_debug.h index 7b665a1..b4dbf80 100644 --- a/proxy/src/gp_debug.h +++ b/proxy/src/gp_debug.h @@ -4,15 +4,25 @@ #define _GP_DEBUG_H_ #include +#include #include +#include extern int gp_debug; -void gp_debug_enable(void); +void gp_debug_enable(int); +void gp_debug_printf(const char *format, ...); +void gp_debug_time_printf(const char *format, ...); #define GPDEBUG(...) do { \ if (gp_debug) { \ - fprintf(stderr, __VA_ARGS__); \ + gp_debug_time_printf(__VA_ARGS__); \ + } \ +} while(0) + +#define GPDEBUGN(lvl, ...) do { \ + if (lvl <= gp_debug) { \ + gp_debug_time_printf(__VA_ARGS__); \ } \ } while(0) -- cgit