From a9edc12523c51211787db80def4f3fe29be31665 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 3 Jun 2026 15:01:03 -0400 Subject: [PATCH] fix(android): release-build Timber tree at WARN+ for operator diagnosis Debug builds got DebugTree; release builds had no tree planted at all, so Timber.w / Timber.e calls were dropped silently in production. That's how the UPnP select diagnostic-prints went invisible during on-device testing - the released APK had no Timber output reaching logcat. Plant a release-only Tree that emits at WARN and above via android.util.Log.println with the canonical 'Minstrel' tag (or the caller-supplied tag when present). Keeps DEBUG / INFO traffic out of production logcat (the chatty stuff is the part we don't want flooding the buffer) while letting operator-driven adb logcat sessions still see real failures. --- .../minstrel/MinstrelApplication.kt | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/com/fabledsword/minstrel/MinstrelApplication.kt b/android/app/src/main/java/com/fabledsword/minstrel/MinstrelApplication.kt index 9aa83efe..d04bb858 100644 --- a/android/app/src/main/java/com/fabledsword/minstrel/MinstrelApplication.kt +++ b/android/app/src/main/java/com/fabledsword/minstrel/MinstrelApplication.kt @@ -158,10 +158,43 @@ class MinstrelApplication : override fun onCreate() { super.onCreate() - if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) + // Debug builds get the full DebugTree (verbose). Release builds + // get a WARN+ tree so operator-driven diagnosis via `adb logcat` + // still surfaces UPnP / cast failures, OkHttp errors, and our + // own Timber.w / Timber.e calls — without the chatty DEBUG / + // INFO traffic flooding the buffer in production. + if (BuildConfig.DEBUG) { + Timber.plant(Timber.DebugTree()) + } else { + Timber.plant(ReleaseTree()) + } appScope.launch { resumeController.restore() } } + /** + * Release-build Timber tree: emits at WARN and above only. + * `android.util.Log` with the canonical tag so `adb logcat` shows + * the line under the standard tag column without falling through + * to the package-stack-trace tag DebugTree produces. + */ + private class ReleaseTree : Timber.Tree() { + override fun isLoggable(tag: String?, priority: Int): Boolean = + priority >= android.util.Log.WARN + + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { + val resolvedTag = tag ?: "Minstrel" + if (t == null) { + android.util.Log.println(priority, resolvedTag, message) + } else { + android.util.Log.println( + priority, + resolvedTag, + message + '\n' + android.util.Log.getStackTraceString(t), + ) + } + } + } + override val workManagerConfiguration: Configuration get() = Configuration.Builder() .setWorkerFactory(workerFactory)