Skip to content

Commit 88c973e

Browse files
Refactor logging behavior for release builds and update ACRA logging configuration
1 parent 4d91a9e commit 88c973e

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ android {
7070
signingConfig = signingConfigs.getByName("release")
7171
}
7272

73+
isDebuggable = false
7374
isMinifyEnabled = true
7475
isShrinkResources = true
7576
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")

app/src/main/java/org/jellyfin/androidtv/LogInitializer.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,19 @@ class LogInitializer : Initializer<Unit> {
2020
}
2121

2222
// Initialize the logging library
23-
Timber.plant(Timber.DebugTree())
24-
Timber.i("Debug tree planted")
23+
if (BuildConfig.DEBUG) {
24+
Timber.plant(Timber.DebugTree())
25+
} else {
26+
// Release builds: only log warnings and errors
27+
Timber.plant(object : Timber.Tree() {
28+
override fun log(priority: Int, tag: String?, message: String, t: Throwable?) {
29+
if (priority >= android.util.Log.WARN) {
30+
android.util.Log.println(priority, tag ?: "Moonfin", message)
31+
}
32+
}
33+
})
34+
}
35+
Timber.i("Timber initialized")
2536
}
2637

2738
override fun dependencies() = emptyList<Class<out Initializer<*>>>()

app/src/main/java/org/jellyfin/androidtv/telemetry/TelemetryService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object TelemetryService {
3232
* Call in the attachBaseContext function of the application.
3333
*/
3434
fun init(context: Application) {
35-
ACRA.DEV_LOGGING = true
35+
ACRA.DEV_LOGGING = BuildConfig.DEBUG
3636
context.initAcra {
3737
buildConfigClass = BuildConfig::class.java
3838
sharedPreferencesName = TelemetryPreferences.SHARED_PREFERENCES_NAME

0 commit comments

Comments
 (0)