Skip to content

Commit

Permalink
print INFO and upper Android log in release mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kaaass committed May 23, 2022
1 parent 696b9fd commit b57a0f0
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions loader/dyn_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down Expand Up @@ -139,24 +143,36 @@ 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];

va_start(list, 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;
}
Expand Down

0 comments on commit b57a0f0

Please sign in to comment.