···561561} GPU_DebugLevelEnum;
562562563563564564+/*! \ingroup Logging
565565+ * Type enumeration for logging levels.
566566+ * \see GPU_SetLogCallback()
567567+ */
568568+typedef enum {
569569+ GPU_LOG_INFO = 0,
570570+ GPU_LOG_WARNING,
571571+ GPU_LOG_ERROR
572572+} GPU_LogLevelEnum;
573573+574574+564575/* Private implementation of renderer members */
565576struct GPU_RendererImpl;
566577···689700690701/*! Prints an error log message. */
691702DECLSPEC void SDLCALL GPU_LogError(const char* format, ...);
703703+704704+/*! Sets a custom callback for handling logging. Use stdio's vsnprintf() to process the va_list into a string. Passing NULL as the callback will reset to the default internal logging. */
705705+DECLSPEC void SDLCALL GPU_SetLogCallback(int (*callback)(GPU_LogLevelEnum log_level, const char* format, va_list args));
692706693707/*! Pushes a new error code onto the error stack. If the stack is full, this function does nothing.
694708 * \param function The name of the function that pushed the error
+36-15
src/SDL_gpu.c
···8989}
909091919292+int GPU_DefaultPrint(GPU_LogLevelEnum log_level, const char* format, va_list args)
9393+{
9494+ switch(log_level)
9595+ {
9696+ #ifdef __ANDROID__
9797+ case GPU_LOG_INFO:
9898+ return __android_log_vprint((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_3? ANDROID_LOG_ERROR : ANDROID_LOG_INFO), "APPLICATION", format, args);
9999+ case GPU_LOG_WARNING:
100100+ return __android_log_vprint((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_2? ANDROID_LOG_ERROR : ANDROID_LOG_WARN), "APPLICATION", format, args);
101101+ case GPU_LOG_ERROR:
102102+ return __android_log_vprint(ANDROID_LOG_ERROR, "APPLICATION", format, args);
103103+ #else
104104+ case GPU_LOG_INFO:
105105+ return vfprintf((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_3? stderr : stdout), format, args);
106106+ case GPU_LOG_WARNING:
107107+ return vfprintf((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_2? stderr : stdout), format, args);
108108+ case GPU_LOG_ERROR:
109109+ return vfprintf(stderr, format, args);
110110+ #endif
111111+ default:
112112+ return 0;
113113+ }
114114+}
115115+116116+static int (*gpu_print)(GPU_LogLevelEnum log_level, const char* format, va_list args) = &GPU_DefaultPrint;
117117+118118+void GPU_SetLogCallback(int (*callback)(GPU_LogLevelEnum log_level, const char* format, va_list args))
119119+{
120120+ if(callback == NULL)
121121+ gpu_print = &GPU_DefaultPrint;
122122+ else
123123+ gpu_print = callback;
124124+}
9212593126void GPU_LogInfo(const char* format, ...)
94127{
95128 va_list args;
96129 va_start(args, format);
9797- #ifdef __ANDROID__
9898- __android_log_vprint((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_3? ANDROID_LOG_ERROR : ANDROID_LOG_INFO), "APPLICATION", format, args);
9999- #else
100100- vfprintf((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_3? stderr : stdout), format, args);
101101- #endif
130130+ gpu_print(GPU_LOG_INFO, format, args);
102131 va_end(args);
103132}
104133···106135{
107136 va_list args;
108137 va_start(args, format);
109109- #ifdef __ANDROID__
110110- __android_log_vprint((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_2? ANDROID_LOG_ERROR : ANDROID_LOG_WARN), "APPLICATION", format, args);
111111- #else
112112- vfprintf((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_2? stderr : stdout), format, args);
113113- #endif
138138+ gpu_print(GPU_LOG_WARNING, format, args);
114139 va_end(args);
115140}
116141···118143{
119144 va_list args;
120145 va_start(args, format);
121121- #ifdef __ANDROID__
122122- __android_log_vprint(ANDROID_LOG_ERROR, "APPLICATION", format, args);
123123- #else
124124- vfprintf(stderr, format, args);
125125- #endif
146146+ gpu_print(GPU_LOG_ERROR, format, args);
126147 va_end(args);
127148}
128149