From b7dd138e829c4102a8627531e6aae2692d71e2e4 Mon Sep 17 00:00:00 2001 From: Jonathan Klee Date: Tue, 18 Apr 2023 11:36:26 +0200 Subject: [PATCH] Add ReleaseTree for Timber logging in Release builds --- .../e/blisslauncher/BlissLauncher.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java index 06682179fb..c6d8f19817 100755 --- a/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java +++ b/app/src/main/java/foundation/e/blisslauncher/BlissLauncher.java @@ -8,6 +8,10 @@ import android.database.ContentObserver; import android.net.Uri; import android.os.Handler; import android.provider.Settings; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; import foundation.e.blisslauncher.core.DeviceProfile; import foundation.e.blisslauncher.core.IconsHandler; @@ -29,6 +33,18 @@ public class BlissLauncher extends Application { private static WidgetHost sAppWidgetHost; private static AppWidgetManager sAppWidgetManager; + private static class ReleaseTree extends Timber.Tree { + + @Override + protected void log(int priority, @Nullable String tag, @NonNull String message, @Nullable Throwable throwable) { + if (priority < Log.INFO) { + return; + } + + Log.println(priority, tag, message); + } + } + @Override public void onCreate() { super.onCreate(); @@ -49,9 +65,10 @@ public class BlissLauncher extends Application { if (!BuildConfig.DEBUG) { Telemetry.init(BuildConfig.SENTRY_DSN, this, true); + Timber.plant(new ReleaseTree()); + } else { + Timber.plant(new Timber.DebugTree()); } - - Timber.plant(new Timber.DebugTree()); } private void onNotificationSettingsChanged() { -- GitLab