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:
parent
1588c20b5b
commit
c2be35f1bf
1 changed files with 18 additions and 0 deletions
18
src/debug.h
18
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 <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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue