From a9d24872a89f9039956993d8290713dcde3f0ead Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Mon, 5 Dec 2022 06:34:33 +0100 Subject: [PATCH] feat(youtube/debugging): print stack traces --- .../integrations/settings/SettingsEnum.java | 2 ++ .../app/revanced/integrations/utils/LogHelper.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java index 476bc90e..e3c2ad8f 100644 --- a/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/integrations/settings/SettingsEnum.java @@ -110,6 +110,8 @@ public enum SettingsEnum { // ReVanced settings DEBUG("revanced_debug_enabled", false, ReturnType.BOOLEAN), + DEBUG_STACKTRACE("revanced_debug_stacktrace_enabled", false, ReturnType.BOOLEAN), + USE_DARK_THEME("app_theme_dark", false, ReturnType.BOOLEAN), // RYD settings diff --git a/app/src/main/java/app/revanced/integrations/utils/LogHelper.java b/app/src/main/java/app/revanced/integrations/utils/LogHelper.java index 51487107..b995eeac 100644 --- a/app/src/main/java/app/revanced/integrations/utils/LogHelper.java +++ b/app/src/main/java/app/revanced/integrations/utils/LogHelper.java @@ -2,6 +2,9 @@ package app.revanced.integrations.utils; import android.util.Log; +import java.io.PrintWriter; +import java.io.StringWriter; + import app.revanced.integrations.settings.SettingsEnum; public class LogHelper { @@ -50,7 +53,16 @@ public class LogHelper { */ public static void printDebug(LogMessage message) { if (SettingsEnum.DEBUG.getBoolean()) { - Log.d("revanced: " + message.findOuterClassSimpleName(), message.buildMessageString()); + var log = new StringBuilder(message.buildMessageString()); + + if (SettingsEnum.DEBUG_STACKTRACE.getBoolean()) { + var sw = new StringWriter(); + new Throwable().printStackTrace(new PrintWriter(sw)); + + log.append(String.format("\n%s", sw)); + } + + Log.d("revanced: " + message.findOuterClassSimpleName(), log.toString()); } }