misc(log): debug log force off

This commit is contained in:
Swung0x48 2025-02-07 15:52:48 +08:00
parent f2685fa2eb
commit b416d6fbb3
3 changed files with 16 additions and 7 deletions

View File

@ -7,12 +7,21 @@
#include "mg.h" #include "mg.h"
#define GLOBAL_DEBUG 0 #define GLOBAL_DEBUG 0
#define GLOBAL_DEBUG_FORCE_OFF 1
#if GLOBAL_DEBUG_FORCE_OFF
#define LOG() {}
#define LOG_D(...) {}
#define LOG_W(...) {}
#define LOG_E(...) {}
#define LOG_F(...) {}
#else
#define LOG() if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, "Use function: %s", __FUNCTION__);printf("Use function: %s\n", __FUNCTION__);write_log("Use function: %s\n", __FUNCTION__);} #define LOG() if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, "Use function: %s", __FUNCTION__);printf("Use function: %s\n", __FUNCTION__);write_log("Use function: %s\n", __FUNCTION__);}
#define LOG_D(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);} #define LOG_D(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);}
#define LOG_W(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_WARN, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);} #define LOG_W(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_WARN, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);}
#define LOG_E(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_ERROR, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);} #define LOG_E(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_ERROR, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);}
#define LOG_F(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_FATAL, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);} #define LOG_F(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_FATAL, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);}
#endif
#define LOG_V(...) {__android_log_print(ANDROID_LOG_VERBOSE, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);} #define LOG_V(...) {__android_log_print(ANDROID_LOG_VERBOSE, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);}
#define LOG_I(...) {__android_log_print(ANDROID_LOG_INFO, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);} #define LOG_I(...) {__android_log_print(ANDROID_LOG_INFO, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n\n");write_log(__VA_ARGS__);}

View File

@ -29,7 +29,7 @@ void glBindFragDataLocation(GLuint program, GLuint color, const GLchar *name) {
char *result = NULL; char *result = NULL;
if (regcomp(&regex, targetPattern, REG_EXTENDED) != 0) { if (regcomp(&regex, targetPattern, REG_EXTENDED) != 0) {
fprintf(stderr, "Failed to compile regex\n"); LOG_E("Failed to compile regex\n");
return; return;
} }
@ -38,7 +38,7 @@ void glBindFragDataLocation(GLuint program, GLuint color, const GLchar *name) {
size_t matchLen = pmatch[0].rm_eo - pmatch[0].rm_so; size_t matchLen = pmatch[0].rm_eo - pmatch[0].rm_so;
origin = (char *)malloc(matchLen + 1); origin = (char *)malloc(matchLen + 1);
if (!origin) { if (!origin) {
fprintf(stderr, "Memory allocation failed\n"); LOG_E("Memory allocation failed\n");
break; break;
} }
strncpy(origin, searchStart + pmatch[0].rm_so, matchLen); strncpy(origin, searchStart + pmatch[0].rm_so, matchLen);
@ -47,7 +47,7 @@ void glBindFragDataLocation(GLuint program, GLuint color, const GLchar *name) {
size_t resultLen = strlen(origin) + 30; // "layout (location = )" + colorNumber + null terminator size_t resultLen = strlen(origin) + 30; // "layout (location = )" + colorNumber + null terminator
result = (char *)malloc(resultLen); result = (char *)malloc(resultLen);
if (!result) { if (!result) {
fprintf(stderr, "Memory allocation failed\n"); LOG_E("Memory allocation failed\n");
free(origin); free(origin);
break; break;
} }
@ -61,7 +61,7 @@ void glBindFragDataLocation(GLuint program, GLuint color, const GLchar *name) {
char *newConverted = (char *)malloc(newLen); char *newConverted = (char *)malloc(newLen);
if (!newConverted) { if (!newConverted) {
fprintf(stderr, "Memory allocation failed\n"); LOG_E("Memory allocation failed\n");
free(origin); free(origin);
free(result); free(result);
break; break;

View File

@ -116,9 +116,9 @@ static name##_PTR egl_##name = NULL; \
ERR = gles_glGetError(); \ ERR = gles_glGetError(); \
} }
#else #else
#define CHECK_GL_ERROR #define CHECK_GL_ERROR {}
#define INIT_CHECK_GL_ERROR #define INIT_CHECK_GL_ERROR {}
#define CHECK_GL_ERROR_NO_INIT #define CHECK_GL_ERROR_NO_INIT {}
#endif #endif
#define INIT_CHECK_GL_ERROR_FORCE \ #define INIT_CHECK_GL_ERROR_FORCE \