瀏覽代碼

android: guard against potential exceptions when dealing with log handlers

j8
Saúl Ibarra Corretgé 5 年之前
父節點
當前提交
a79ae9b576
共有 1 個檔案被更改,包括 15 行新增2 行删除
  1. 15
    2
      android/sdk/src/main/java/org/jitsi/meet/sdk/log/JitsiMeetLogger.java

+ 15
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/log/JitsiMeetLogger.java 查看文件

@@ -24,11 +24,24 @@ public class JitsiMeetLogger {
24 24
     }
25 25
 
26 26
     public static void addHandler(JitsiMeetBaseLogHandler handler) {
27
-        Timber.plant(handler);
27
+        if (!Timber.forest().contains(handler)) {
28
+            try {
29
+                Timber.plant(handler);
30
+            } catch (Throwable t) {
31
+                Timber.w(t, "Couldn't add log handler");
32
+            }
33
+
34
+        }
28 35
     }
29 36
 
30 37
     public static void removeHandler(JitsiMeetBaseLogHandler handler) {
31
-        Timber.uproot(handler);
38
+        if (Timber.forest().contains(handler)) {
39
+            try {
40
+                Timber.uproot(handler);
41
+            } catch (Throwable t) {
42
+                Timber.w(t, "Couldn't remove log handler");
43
+            }
44
+        }
32 45
     }
33 46
 
34 47
     public static void v(String message, Object... args) {

Loading…
取消
儲存