1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

android: hide printf hijack for android logging behind define (#12269)

This commit is contained in:
Larpon 2021-10-22 18:59:25 +02:00 committed by GitHub
parent 8273c0582b
commit 506924b01c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,19 +1,21 @@
#if defined(__ANDROID__) #if defined(V_ANDROID_LOG_PRINT)
// Adapted from https://stackoverflow.com/a/196018/1904615 #if defined(__ANDROID__)
#define V_ANDROID_LOG_STR_VALUE(arg) #arg // Adapted from https://stackoverflow.com/a/196018/1904615
#define V_ANDROID_LOG_NAME(tag_name) V_ANDROID_LOG_STR_VALUE(tag_name) #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 #ifndef V_ANDROID_LOG_TAG
#if defined(APPNAME) #if defined(APPNAME)
#define V_ANDROID_LOG_TAG APPNAME #define V_ANDROID_LOG_TAG APPNAME
#else #else
#define V_ANDROID_LOG_TAG "V_ANDROID" #define V_ANDROID_LOG_TAG "V_ANDROID"
#endif
#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
#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