From b57a0f00b3fd70680e167889191259f65937221b Mon Sep 17 00:00:00 2001 From: KAAAsS Date: Mon, 23 May 2022 16:03:27 +0800 Subject: [PATCH] print INFO and upper Android log in release mode --- loader/dyn_stub.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/loader/dyn_stub.c b/loader/dyn_stub.c index ba91bc5..c552fe4 100644 --- a/loader/dyn_stub.c +++ b/loader/dyn_stub.c @@ -86,7 +86,11 @@ size_t __strlen_chk(const char *s, size_t s_len) { void check_last_error() { if (*g_is_error) { +#if defined(DEBUG) debugPrintf("[LastError]: %s\n", *last_error); +#else + printf("[LastError]: %s\n", *last_error); +#endif } } @@ -139,7 +143,6 @@ void _ZNSt6__ndk15mutexD1Ev(void **mutex) { } int __android_log_print(int prio, const char *tag, const char *fmt, ...) { -#ifdef DEBUG va_list list; static char string[0x8000]; @@ -147,16 +150,29 @@ int __android_log_print(int prio, const char *tag, const char *fmt, ...) { vsprintf(string, fmt, list); va_end(list); +#if defined(DEBUG) debugPrintf("[LOG] %s: %s\n", tag, string); check_last_error(); +#else + if (prio >= 4) { + // only show INFO and upper in release mode + printf("[LOG] %s: %s\n", tag, string); + check_last_error(); + } #endif return 0; } int __android_log_write(int prio, const char *tag, const char *text) { -#ifdef DEBUG - printf("[LOG] %s: %s\n", tag, text); +#if defined(DEBUG) + debugPrintf("[LOG] %s: %s\n", tag, text); check_last_error(); +#else + if (prio >= 4) { + // only show INFO and upper in release mode + printf("[LOG] %s: %s\n", tag, text); + check_last_error(); + } #endif return 0; }