From e0fef026317ba1af40cb1b3b4e3dad1679f024be Mon Sep 17 00:00:00 2001 From: Joshua Horton Date: Tue, 20 May 2025 13:30:38 +0700 Subject: [PATCH] change(android): address PR review concerns --- .../src/main/java/com/keyman/engine/util/KMLog.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/android/KMEA/app/src/main/java/com/keyman/engine/util/KMLog.java b/android/KMEA/app/src/main/java/com/keyman/engine/util/KMLog.java index 9c8f4a8f57..1ce55bf0ce 100644 --- a/android/KMEA/app/src/main/java/com/keyman/engine/util/KMLog.java +++ b/android/KMEA/app/src/main/java/com/keyman/engine/util/KMLog.java @@ -29,6 +29,10 @@ public final class KMLog { private static final String MODEL_TAG = "modelId"; private static final String LANGCODE_TAG = "languageCode"; + // Some of the methods used to generate debug logging information can, themselves, + // trigger errors that can also trigger the same logging. We must not get + // caught in an infinite loop / stack-overflow; this field helps us avoid states + // that would otherwise cause error-looping, etc. private static boolean isLogging = false; private static void tagDebugInfo() { @@ -52,7 +56,9 @@ public final class KMLog { } } } - } catch (Exception ignored) { + } catch (Exception ex) { + String msg = ex.getMessage() == null ? "" : ex.getMessage(); + Sentry.setExtra("debugLoggingError", msg); } Sentry.setExtra(KEYBOARD_TAG, kbdId); Sentry.setExtra(KEYBOARD_COUNT_TAG, "" + kbdCount); @@ -212,6 +218,8 @@ public final class KMLog { } // Report the original exception LogException(tag, msg, e); + // And remove the exception-specific tagged data, lest it also be + // tracked on subsequent errors not associated with the current call. Sentry.removeExtra(objName); } isLogging = false;