Add setting to increase logging verbosity (#354)

Adds a toggle to increase the verbosity of the app logs for
release/production builds

Most users won't need to use this, but it can be helpful when [gathering
app
logs](https://github.com/damontecres/Wholphin/wiki/Gathering-app-logs)
to report an issue.
This commit is contained in:
damontecres 2025-11-30 17:27:41 -05:00 committed by GitHub
parent a320875af6
commit eca3268a7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,42 @@
package com.github.damontecres.wholphin.util
import android.util.Log
import com.github.damontecres.wholphin.BuildConfig
import timber.log.Timber
class DebugLogTree private constructor() : Timber.Tree() {
// Only add logging for below INFO, production logger in WholphinApplication logs >=INFO
override fun isLoggable(
tag: String?,
priority: Int,
): Boolean = priority < Log.INFO && !BuildConfig.DEBUG
override fun log(
priority: Int,
tag: String?,
message: String,
t: Throwable?,
) {
Log.println(priority, tag ?: "Wholphin", message)
}
var enabled: Boolean
get() = Timber.forest().contains(this)
set(value) {
synchronized(this) {
if (value) {
if (!Timber.forest().contains(this)) {
Timber.plant(this)
}
} else {
if (Timber.forest().contains(this)) {
Timber.uproot(this)
}
}
}
}
companion object {
val INSTANCE = DebugLogTree()
}
}