--- a/src/Libraries/LG/Source/LOG/src/log.c +++ b/src/Libraries/LG/Source/LOG/src/log.c @@ -28,6 +28,10 @@ #include "log.h" +#ifdef __ANDROID__ +#include +#endif + static struct { void *udata; log_LockFn lock; @@ -99,6 +103,23 @@ time_t t = time(NULL); struct tm *lt = localtime(&t); +#ifdef __ANDROID__ + /* Plain stdout/stderr isn't captured by logcat on this platform (unlike + e.g. gl4es's own "LIBGL"-tagged logging, which goes through this same + API directly) - route there instead so every existing INFO/DEBUG/WARN/ + ERROR call site in the engine becomes visible for on-device debugging, + with no changes needed at those call sites. */ + if (!L.quiet) { + static const int android_priority[] = { + ANDROID_LOG_VERBOSE, ANDROID_LOG_DEBUG, ANDROID_LOG_INFO, + ANDROID_LOG_WARN, ANDROID_LOG_ERROR, ANDROID_LOG_FATAL + }; + va_list args; + va_start(args, fmt); + __android_log_vprint(android_priority[level], "QuestShock", fmt, args); + va_end(args); + } +#else /* Log to stderr */ if (!L.quiet) { va_list args; @@ -116,6 +137,7 @@ va_end(args); fprintf(stderr, "\n"); } +#endif /* Log to file */ if (L.fp) {