mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
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:
parent
a320875af6
commit
eca3268a7d
6 changed files with 65 additions and 0 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue