Sfoglia il codice sorgente

android: guard against potential exceptions when dealing with log handlers

master
Saúl Ibarra Corretgé 5 anni fa
parent
commit
a79ae9b576

+ 15
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/log/JitsiMeetLogger.java Vedi File

@@ -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…
Annulla
Salva