The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

aux/util: Port logging for Android.

Now if u_logging is used, it goes to logcat.

+57
+1
CMakeLists.txt
··· 88 88 find_library(RT_LIBRARY rt) 89 89 if(ANDROID) 90 90 find_library(ANDROID_LIBRARY android) 91 + find_library(ANDROID_LOG_LIBRARY log) 91 92 endif() 92 93 93 94 # This one is named differently because that's what CTest uses
+3
src/xrt/auxiliary/CMakeLists.txt
··· 199 199 else() 200 200 target_link_libraries(aux_util PUBLIC xrt-external-cjson) 201 201 endif() 202 + if(ANDROID) 203 + target_link_libraries(aux_util PUBLIC ${ANDROID_LOG_LIBRARY}) 204 + endif() 202 205 203 206 # Tracking library. 204 207 add_library(aux_tracking STATIC ${TRACKING_SOURCE_FILES})
+53
src/xrt/auxiliary/util/u_logging.c
··· 8 8 */ 9 9 10 10 #include "util/u_logging.h" 11 + #include "xrt/xrt_config_os.h" 11 12 12 13 #include <assert.h> 13 14 #include <stdio.h> 14 15 #include <stdarg.h> 15 16 16 17 18 + #ifdef XRT_OS_ANDROID 19 + 20 + #include <android/log.h> 21 + 22 + static android_LogPriority 23 + u_log_convert_priority(enum u_logging_level level) 24 + { 25 + switch (level) { 26 + case U_LOGGING_TRACE: return ANDROID_LOG_VERBOSE; 27 + case U_LOGGING_DEBUG: return ANDROID_LOG_DEBUG; 28 + case U_LOGGING_INFO: return ANDROID_LOG_INFO; 29 + case U_LOGGING_WARN: return ANDROID_LOG_WARN; 30 + case U_LOGGING_ERROR: return ANDROID_LOG_ERROR; 31 + case U_LOGGING_RAW: return ANDROID_LOG_INFO; 32 + default: break; 33 + } 34 + return ANDROID_LOG_INFO; 35 + } 36 + void 37 + u_log(const char *file, 38 + int line, 39 + const char *func, 40 + enum u_logging_level level, 41 + const char *format, 42 + ...) 43 + { 44 + // print_prefix(func, level); 45 + android_LogPriority prio = u_log_convert_priority(level); 46 + va_list args; 47 + va_start(args, format); 48 + __android_log_vprint(prio, func, format, args); 49 + va_end(args); 50 + } 51 + 52 + void 53 + u_log_xdev(const char *file, 54 + int line, 55 + const char *func, 56 + enum u_logging_level level, 57 + struct xrt_device *xdev, 58 + const char *format, 59 + ...) 60 + { 61 + android_LogPriority prio = u_log_convert_priority(level); 62 + va_list args; 63 + va_start(args, format); 64 + __android_log_vprint(prio, func, format, args); 65 + va_end(args); 66 + } 67 + 68 + #else 17 69 /* 18 70 * 19 71 * Helper functions. ··· 81 133 82 134 fprintf(stderr, "\n"); 83 135 } 136 + #endif