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)