[Chore] (log): LOG_D_N

This commit is contained in:
Swung0x48 2025-04-24 12:13:51 +08:00
parent e3c7bab0af
commit 15cb85835f
3 changed files with 18 additions and 2 deletions

View File

@ -25,6 +25,7 @@ const char *glEnumToString(GLenum e);
#if GLOBAL_DEBUG_FORCE_OFF #if GLOBAL_DEBUG_FORCE_OFF
#define LOG() {} #define LOG() {}
#define LOG_D(...) {} #define LOG_D(...) {}
#define LOG_D_N(...) {}
#define LOG_W(...) {} #define LOG_W(...) {}
#define LOG_E(...) {} #define LOG_E(...) {}
#define LOG_F(...) {} #define LOG_F(...) {}
@ -44,10 +45,11 @@ const char *glEnumToString(GLenum e);
void log_unique_function(const char* func_name); void log_unique_function(const char* func_name);
#else #else
#define LOG() \ #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 #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(...) 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_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_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__);} #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 #define MOBILEGLUES_LOG_H
#endif //MOBILEGLUES_LOG_H #endif //MOBILEGLUES_LOG_H

View File

@ -38,6 +38,18 @@ void write_log(const char* format, ...) {
//fclose(file); //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() { void clear_log() {
file = fopen(log_file_path, "w"); file = fopen(log_file_path, "w");
if (file == nullptr) { if (file == nullptr) {

View File

@ -63,6 +63,8 @@ void start_log();
void write_log(const char *format, ...); void write_log(const char *format, ...);
void write_log_n(const char *format, ...);
void clear_log(); void clear_log();
#ifdef __cplusplus #ifdef __cplusplus