tuxpaint-pencil-sharpener/src/debug.h
Bill Kendrick dfba73d327 Address some compile-time warnings in SDL 2.0
Also disable VERBOSE DEBUG output.

Note - Still a pair of nasty warnings about the following

 * ‘rsvg_handle_close’ is deprecated: Use
   'rsvg_handle_read_stream_sync' instead

 * passing argument 3 of ‘autoscale_copy_smear_free’ from incompatible
   pointer type (SDL_BlitSurface)

They should be addressed.
2022-05-19 00:49:48 -07:00

52 lines
1.4 KiB
C

//#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, line %d in %s() @ %s", __FILE__, __LINE__, __FUNCTION__, ctime(&now)); \
printf(args); \
} while(0)
#endif
/*
* Define a convenience macro DEBUG_PRINTF(). This macro resolves to printf()
* if and only if DEBUG is enabled, otherwise resolves to nothing. In other
* words,
*
* DEBUG_PRINTF("Hello, world!\n");
*
* ... is equivalent to:
*
* #if defined(DEBUG)
* printf("Hello, world!\n");
* #endif
*
* (To be precise, the semicolon falls outside of the #if test, but an empty
* semicolon resolves to nothing in standard C.)
*
* If VERBOSE logging is enabled, DEBUG_PRINTF should resolve to the verbose
* version of printf() defined earlier in this file.
*/
#if defined(DEBUG)
#define DEBUG_PRINTF(...) printf(__VA_ARGS__)
#else
#define DEBUG_PRINTF(...)
#endif
#ifdef __ANDROID__
#include <android/log.h>
#define LOG_TAG "TuxPaint"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
#endif