this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Added GPU_SetLogCallback() and GPU_LogLevelEnum so you can set up custom logging output.

+50 -15
+14
include/SDL_gpu.h
··· 561 561 } GPU_DebugLevelEnum; 562 562 563 563 564 + /*! \ingroup Logging 565 + * Type enumeration for logging levels. 566 + * \see GPU_SetLogCallback() 567 + */ 568 + typedef enum { 569 + GPU_LOG_INFO = 0, 570 + GPU_LOG_WARNING, 571 + GPU_LOG_ERROR 572 + } GPU_LogLevelEnum; 573 + 574 + 564 575 /* Private implementation of renderer members */ 565 576 struct GPU_RendererImpl; 566 577 ··· 689 700 690 701 /*! Prints an error log message. */ 691 702 DECLSPEC void SDLCALL GPU_LogError(const char* format, ...); 703 + 704 + /*! 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. */ 705 + DECLSPEC void SDLCALL GPU_SetLogCallback(int (*callback)(GPU_LogLevelEnum log_level, const char* format, va_list args)); 692 706 693 707 /*! Pushes a new error code onto the error stack. If the stack is full, this function does nothing. 694 708 * \param function The name of the function that pushed the error
+36 -15
src/SDL_gpu.c
··· 89 89 } 90 90 91 91 92 + int GPU_DefaultPrint(GPU_LogLevelEnum log_level, const char* format, va_list args) 93 + { 94 + switch(log_level) 95 + { 96 + #ifdef __ANDROID__ 97 + case GPU_LOG_INFO: 98 + return __android_log_vprint((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_3? ANDROID_LOG_ERROR : ANDROID_LOG_INFO), "APPLICATION", format, args); 99 + case GPU_LOG_WARNING: 100 + return __android_log_vprint((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_2? ANDROID_LOG_ERROR : ANDROID_LOG_WARN), "APPLICATION", format, args); 101 + case GPU_LOG_ERROR: 102 + return __android_log_vprint(ANDROID_LOG_ERROR, "APPLICATION", format, args); 103 + #else 104 + case GPU_LOG_INFO: 105 + return vfprintf((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_3? stderr : stdout), format, args); 106 + case GPU_LOG_WARNING: 107 + return vfprintf((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_2? stderr : stdout), format, args); 108 + case GPU_LOG_ERROR: 109 + return vfprintf(stderr, format, args); 110 + #endif 111 + default: 112 + return 0; 113 + } 114 + } 115 + 116 + static int (*gpu_print)(GPU_LogLevelEnum log_level, const char* format, va_list args) = &GPU_DefaultPrint; 117 + 118 + void GPU_SetLogCallback(int (*callback)(GPU_LogLevelEnum log_level, const char* format, va_list args)) 119 + { 120 + if(callback == NULL) 121 + gpu_print = &GPU_DefaultPrint; 122 + else 123 + gpu_print = callback; 124 + } 92 125 93 126 void GPU_LogInfo(const char* format, ...) 94 127 { 95 128 va_list args; 96 129 va_start(args, format); 97 - #ifdef __ANDROID__ 98 - __android_log_vprint((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_3? ANDROID_LOG_ERROR : ANDROID_LOG_INFO), "APPLICATION", format, args); 99 - #else 100 - vfprintf((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_3? stderr : stdout), format, args); 101 - #endif 130 + gpu_print(GPU_LOG_INFO, format, args); 102 131 va_end(args); 103 132 } 104 133 ··· 106 135 { 107 136 va_list args; 108 137 va_start(args, format); 109 - #ifdef __ANDROID__ 110 - __android_log_vprint((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_2? ANDROID_LOG_ERROR : ANDROID_LOG_WARN), "APPLICATION", format, args); 111 - #else 112 - vfprintf((GPU_GetDebugLevel() >= GPU_DEBUG_LEVEL_2? stderr : stdout), format, args); 113 - #endif 138 + gpu_print(GPU_LOG_WARNING, format, args); 114 139 va_end(args); 115 140 } 116 141 ··· 118 143 { 119 144 va_list args; 120 145 va_start(args, format); 121 - #ifdef __ANDROID__ 122 - __android_log_vprint(ANDROID_LOG_ERROR, "APPLICATION", format, args); 123 - #else 124 - vfprintf(stderr, format, args); 125 - #endif 146 + gpu_print(GPU_LOG_ERROR, format, args); 126 147 va_end(args); 127 148 } 128 149