From f69fee21a868295f9fd6ae457dac3022b2ad28a5 Mon Sep 17 00:00:00 2001 From: Enginex0 Date: Thu, 4 Jun 2026 21:15:34 +0100 Subject: [PATCH] chore(debug): co-locate per-UID logs with dumps Per-UID dossier logs moved from /data/adb/tricky_store/logs to /data/local/tmp/teesim, beside the .bin dumps, so the whole debug trail comes off the device in one `adb pull /data/local/tmp/teesim/` with no root and no /sdcard hop. The release purge now sweeps .log/.log.1 from the diagnostic dir and keeps legacy sweeps of both old locations (loose /data/local/tmp and the module config dir) so upgrading to a release build leaves nothing behind. Repoint package.sh --clear-logs to the new path. --- app/src/main/java/org/matrix/TEESimulator/App.kt | 10 +++++++--- .../org/matrix/TEESimulator/logging/SystemLogger.kt | 4 +++- scripts/package.sh | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/org/matrix/TEESimulator/App.kt b/app/src/main/java/org/matrix/TEESimulator/App.kt index ef9c148..837a2fb 100644 --- a/app/src/main/java/org/matrix/TEESimulator/App.kt +++ b/app/src/main/java/org/matrix/TEESimulator/App.kt @@ -81,14 +81,18 @@ object App { */ private fun purgeDebugDiagnostics() { if (SystemLogger.isDebugBuild) return + // .bin dumps and per-UID logs now share the diagnostic dir. purgeStale(File(InterceptorUtils.DIAGNOSTIC_DIR), InterceptorUtils.DIAGNOSTIC_DIR) { name -> - name.startsWith("teesim-") && name.endsWith(".bin") + name.startsWith("teesim-") && + (name.endsWith(".bin") || name.endsWith(".log") || name.endsWith(".log.1")) } - // Older debug installs wrote the dumps loose in /data/local/tmp; sweep those too. + // Older debug installs wrote dumps loose in /data/local/tmp and per-UID logs under the + // module config dir; sweep both legacy locations so upgrading to a release build leaves + // nothing behind. purgeStale(File("/data/local/tmp"), "/data/local/tmp") { name -> name.startsWith("teesim-") && name.endsWith(".bin") } - purgeStale(File("${ConfigurationManager.CONFIG_PATH}/logs"), "per-UID log dir") { name -> + purgeStale(File("${ConfigurationManager.CONFIG_PATH}/logs"), "legacy per-UID log dir") { name -> name.startsWith("teesim-uid-") && (name.endsWith(".log") || name.endsWith(".log.1")) } } diff --git a/app/src/main/java/org/matrix/TEESimulator/logging/SystemLogger.kt b/app/src/main/java/org/matrix/TEESimulator/logging/SystemLogger.kt index f450aeb..bc8121e 100644 --- a/app/src/main/java/org/matrix/TEESimulator/logging/SystemLogger.kt +++ b/app/src/main/java/org/matrix/TEESimulator/logging/SystemLogger.kt @@ -161,7 +161,9 @@ object SystemLogger { uidLog(uid, txId, event, detail()) } - private val uidLogDir = File(ConfigurationManager.CONFIG_PATH, "logs") + // Co-located with the .bin dumps in InterceptorUtils.DIAGNOSTIC_DIR so every debug artifact sits + // in one adb-pullable dir; release builds purge it (see App.purgeDebugDiagnostics). + private val uidLogDir = File("/data/local/tmp/teesim") private const val UID_LOG_MAX_BYTES = 4L * 1024 * 1024 private val uidWriters = ConcurrentHashMap() diff --git a/scripts/package.sh b/scripts/package.sh index 28be31e..c029ca4 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -158,7 +158,7 @@ deploy_zip() { if [[ "$CLEAR_LOGS" == true ]]; then bold "==> Clearing per-UID diagnostic logs" - adb shell "rm -f /data/adb/tricky_store/logs/teesim-uid-*" 2>/dev/null || true + adb shell "rm -f /data/local/tmp/teesim/teesim-uid-*" 2>/dev/null || true fi bold "==> Deploying $name"