android: provide more predictable logging, add comptime termux support (#14984)

This commit is contained in:
Larpon 2022-07-07 17:28:29 +02:00 committed by GitHub
parent 71a85249ea
commit 9f3b6e3e3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 49 additions and 44 deletions

View file

@ -1,21 +0,0 @@
#if defined(V_ANDROID_LOG_PRINT)
#if defined(__ANDROID__)
// Adapted from https://stackoverflow.com/a/196018/1904615
#define V_ANDROID_LOG_STR_VALUE(arg) #arg
#define V_ANDROID_LOG_NAME(tag_name) V_ANDROID_LOG_STR_VALUE(tag_name)
#ifndef V_ANDROID_LOG_TAG
#if defined(APPNAME)
#define V_ANDROID_LOG_TAG APPNAME
#else
#define V_ANDROID_LOG_TAG "V_ANDROID"
#endif
#endif
#define V_ANDROID_LOG_TAG_NAME V_ANDROID_LOG_NAME(V_ANDROID_LOG_TAG)
#include <android/log.h>
#define printf(...) __android_log_print(ANDROID_LOG_INFO, V_ANDROID_LOG_TAG_NAME, __VA_ARGS__)
#define fprintf(a, ...) __android_log_print(ANDROID_LOG_ERROR, V_ANDROID_LOG_TAG_NAME, __VA_ARGS__)
#endif
#endif