From c2be35f1bf54f0dee86897bd42c035a735ca99cc Mon Sep 17 00:00:00 2001 From: Mark Kim Date: Sun, 23 Sep 2018 21:35:31 -0400 Subject: [PATCH] Verbose logging. Verbose logging adds metadata about when it is called and from where to every printf call. Enable it by uncommenting both DEBUG and VERBOSE defined constants in debug.h. --- src/debug.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/debug.h b/src/debug.h index 9c5ec37b3..5d5f62a5b 100644 --- a/src/debug.h +++ b/src/debug.h @@ -1 +1,19 @@ /* #define DEBUG */ +/* #define VERBOSE */ + +/* +* Enable verbose logging if requested on platforms that support it. +* +* Verbose logging adds metadata to printf, including the source file location +* from where printf was called and the time it was called at runtime. +*/ +#if defined(DEBUG) && defined(VERBOSE) && defined(__GNUC__) +#include +#include + +#define printf(args...) do { \ + time_t now = time(NULL); \ + printf("\n### %s, %d @ %s", __FILE__, __LINE__, ctime(&now)); \ + printf(args); \ +} while(0) +#endif