From 15cb85835febf4b9fd0c6e55f61e949864ece532 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 24 Apr 2025 12:13:51 +0800 Subject: [PATCH] [Chore] (log): LOG_D_N --- src/main/cpp/gl/log.h | 6 ++++-- src/main/cpp/gl/mg.cpp | 12 ++++++++++++ src/main/cpp/gl/mg.h | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/cpp/gl/log.h b/src/main/cpp/gl/log.h index 8f8b12f..459183d 100644 --- a/src/main/cpp/gl/log.h +++ b/src/main/cpp/gl/log.h @@ -25,6 +25,7 @@ const char *glEnumToString(GLenum e); #if GLOBAL_DEBUG_FORCE_OFF #define LOG() {} #define LOG_D(...) {} +#define LOG_D_N(...) {} #define LOG_W(...) {} #define LOG_E(...) {} #define LOG_F(...) {} @@ -44,10 +45,11 @@ const char *glEnumToString(GLenum e); void log_unique_function(const char* func_name); #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__);} + if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, "\nUse function: %s", __FUNCTION__);printf("\nUse function: %s\n", __FUNCTION__);write_log("\nUse function: %s\n", __FUNCTION__);} #endif #define LOG_D(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\n");write_log(__VA_ARGS__);} +#define LOG_D_N(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_DEBUG, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);write_log_n(__VA_ARGS__);} #define LOG_W(...) if(DEBUG||GLOBAL_DEBUG) {__android_log_print(ANDROID_LOG_WARN, RENDERERNAME, __VA_ARGS__);printf(__VA_ARGS__);printf("\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");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");write_log(__VA_ARGS__);} @@ -59,4 +61,4 @@ void log_unique_function(const char* func_name); #define MOBILEGLUES_LOG_H -#endif //MOBILEGLUES_LOG_H +#endif //MOBILEGLUES_LOG_H \ No newline at end of file diff --git a/src/main/cpp/gl/mg.cpp b/src/main/cpp/gl/mg.cpp index 9578b4f..e8d38a0 100644 --- a/src/main/cpp/gl/mg.cpp +++ b/src/main/cpp/gl/mg.cpp @@ -38,6 +38,18 @@ void write_log(const char* format, ...) { //fclose(file); } +void write_log_n(const char* format, ...) { + if (file == NULL) { + return; + } + va_list args; + va_start(args, format); + vfprintf(file, format, args); + va_end(args); + // Todo: close file + fflush(file); +} + void clear_log() { file = fopen(log_file_path, "w"); if (file == nullptr) { diff --git a/src/main/cpp/gl/mg.h b/src/main/cpp/gl/mg.h index 2d7ee3e..7285979 100644 --- a/src/main/cpp/gl/mg.h +++ b/src/main/cpp/gl/mg.h @@ -63,6 +63,8 @@ void start_log(); void write_log(const char *format, ...); +void write_log_n(const char *format, ...); + void clear_log(); #ifdef __cplusplus