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.
This commit is contained in:
Mark Kim 2018-09-23 21:35:31 -04:00
parent 1588c20b5b
commit c2be35f1bf

View file

@ -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 <stdio.h>
#include <time.h>
#define printf(args...) do { \
time_t now = time(NULL); \
printf("\n### %s, %d @ %s", __FILE__, __LINE__, ctime(&now)); \
printf(args); \
} while(0)
#endif