From fc830bc5b410be63b2e6a780dc9c3eded86d62c5 Mon Sep 17 00:00:00 2001 From: Rylie Pavlik Date: Fri, 10 May 2024 15:26:49 -0500 Subject: [PATCH] a/util: Prepend "monado" to function name on android logcat For easier searching. Part-of: --- doc/changes/misc_features/mr.676.md | 1 + src/xrt/auxiliary/util/u_logging.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/changes/misc_features/mr.676.md b/doc/changes/misc_features/mr.676.md index 9fa173263..c2967f928 100644 --- a/doc/changes/misc_features/mr.676.md +++ b/doc/changes/misc_features/mr.676.md @@ -15,6 +15,7 @@ - mr.1372 - mr.1377 - mr.1385 +- mr.2232 --- More improvements to the Android port. diff --git a/src/xrt/auxiliary/util/u_logging.c b/src/xrt/auxiliary/util/u_logging.c index b20253582..68a30dff8 100644 --- a/src/xrt/auxiliary/util/u_logging.c +++ b/src/xrt/auxiliary/util/u_logging.c @@ -50,6 +50,11 @@ */ #define LOG_HEX_LINE_BUF_SIZE (128) + +#ifndef LOG_ANDROID_TAG_PREFIX +#define LOG_ANDROID_TAG_PREFIX "monado" +#endif + /* * * Global log level functions. @@ -381,10 +386,15 @@ do_print(const char *file, int line, const char *func, enum u_logging_level leve #ifdef XRT_OS_ANDROID - android_LogPriority prio = u_log_convert_priority(level); - __android_log_write(prio, func, storage); + char storage_tag[256]; + int tag_ret = u_truncate_snprintf(storage_tag, sizeof(storage_tag), LOG_ANDROID_TAG_PREFIX ".%s", func); + if (tag_ret < 0) { + __android_log_write(prio, func, storage); + } else { + __android_log_write(prio, storage_tag, storage); + } #elif defined XRT_OS_WINDOWS || defined XRT_OS_LINUX // We want a newline, so add it, then null-terminate again.