Chromium Code Reviews| Index: webrtc/base/java/src/org/webrtc/Logging.java |
| diff --git a/webrtc/base/java/src/org/webrtc/Logging.java b/webrtc/base/java/src/org/webrtc/Logging.java |
| index aea4ffb23ed57a50d151409c52ce81b4cb03eaa4..ea1bca3bdb18fd99a6885226254531acd647dcd7 100644 |
| --- a/webrtc/base/java/src/org/webrtc/Logging.java |
| +++ b/webrtc/base/java/src/org/webrtc/Logging.java |
| @@ -19,14 +19,18 @@ import java.util.logging.Level; |
| /** Java wrapper for WebRTC logging. */ |
| public class Logging { |
| private static final Logger fallbackLogger = Logger.getLogger("org.webrtc.Logging"); |
| - private static boolean tracingEnabled; |
| + private static volatile boolean tracingEnabled; |
| + private static volatile boolean nativeLibLoaded; |
| static { |
| try { |
| System.loadLibrary("jingle_peerconnection_so"); |
| - } catch (Throwable t) { |
| + nativeLibLoaded = true; |
| + } catch (UnsatisfiedLinkError t) { |
| // If native logging is unavailable, log to system log. |
| fallbackLogger.setLevel(Level.ALL); |
| + |
| + fallbackLogger.log(Level.WARNING, "Failed to load jingle_peerconnection_so: ", t); |
| } |
| } |
| @@ -60,10 +64,19 @@ public class Logging { |
| }; |
| public static void enableLogThreads() { |
| + if (!nativeLibLoaded) { |
| + fallbackLogger.log(Level.WARNING, "Cannot enable log thread because native lib not loaded."); |
| + return; |
| + } |
| nativeEnableLogThreads(); |
| } |
| public static void enableLogTimeStamps() { |
| + if (!nativeLibLoaded) { |
| + fallbackLogger.log(Level.WARNING, |
| + "Cannot enable log timestamps because native lib not loaded."); |
| + return; |
| + } |
| nativeEnableLogTimeStamps(); |
| } |
| @@ -71,6 +84,11 @@ public class Logging { |
| // On Android, use "logcat:" for |path| to send output there. |
| public static synchronized void enableTracing( |
| String path, EnumSet<TraceLevel> levels, Severity severity) { |
| + if (!nativeLibLoaded) { |
| + fallbackLogger.log(Level.WARNING, "Cannot enable tracing because native lib not loaded."); |
| + return; |
| + } |
| + |
| if (tracingEnabled) { |
| return; |
| } |
| @@ -84,12 +102,8 @@ public class Logging { |
| public static void log(Severity severity, String tag, String message) { |
| if (tracingEnabled) { |
|
jiayl2
2015/10/02 15:09:09
Note: tracingEnabled should only be true when nati
phoglund
2015/10/05 08:37:28
Acknowledged.
|
| - try { |
| - nativeLog(severity.ordinal(), tag, message); |
| - return; |
| - } catch (Throwable t) { |
| - // Don't log the error to avoid spamming. |
| - } |
| + nativeLog(severity.ordinal(), tag, message); |
| + return; |
| } |
| // Fallback to system log. |