Add back loading native library in Logging.java.
Some applications enable logging before using PeerConnectionFactory. Not loading native library in Logging.java broke these applications. TBR=magjed@webrtc.org Bug: webrtc:7474, b/67419105 Change-Id: I5984d2241cfb76e0edb5b5da0974c8693bf50603 Reviewed-on: https://webrtc-review.googlesource.com/6600 Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20151}
This commit is contained in:

committed by
Commit Bot

parent
6661764acc
commit
c177168d1e
@ -30,6 +30,8 @@ import java.util.logging.Logger;
|
||||
public class Logging {
|
||||
private static final Logger fallbackLogger = createFallbackLogger();
|
||||
private static volatile boolean loggingEnabled;
|
||||
private static enum NativeLibStatus { UNINITIALIZED, LOADED, FAILED }
|
||||
private static volatile NativeLibStatus nativeLibStatus = NativeLibStatus.UNINITIALIZED;
|
||||
|
||||
private static Logger createFallbackLogger() {
|
||||
final Logger fallbackLogger = Logger.getLogger("org.webrtc.Logging");
|
||||
@ -37,6 +39,19 @@ public class Logging {
|
||||
return fallbackLogger;
|
||||
}
|
||||
|
||||
private static boolean loadNativeLibrary() {
|
||||
if (nativeLibStatus == NativeLibStatus.UNINITIALIZED) {
|
||||
try {
|
||||
System.loadLibrary("jingle_peerconnection_so");
|
||||
nativeLibStatus = NativeLibStatus.LOADED;
|
||||
} catch (UnsatisfiedLinkError t) {
|
||||
nativeLibStatus = NativeLibStatus.FAILED;
|
||||
fallbackLogger.log(Level.WARNING, "Failed to load jingle_peerconnection_so: ", t);
|
||||
}
|
||||
}
|
||||
return nativeLibStatus == NativeLibStatus.LOADED;
|
||||
}
|
||||
|
||||
// TODO(solenberg): Remove once dependent projects updated.
|
||||
@Deprecated
|
||||
public enum TraceLevel {
|
||||
@ -66,22 +81,34 @@ public class Logging {
|
||||
public enum Severity { LS_SENSITIVE, LS_VERBOSE, LS_INFO, LS_WARNING, LS_ERROR, LS_NONE }
|
||||
|
||||
public static void enableLogThreads() {
|
||||
if (!loadNativeLibrary()) {
|
||||
fallbackLogger.log(Level.WARNING, "Cannot enable log thread because native lib not loaded.");
|
||||
return;
|
||||
}
|
||||
nativeEnableLogThreads();
|
||||
}
|
||||
|
||||
public static void enableLogTimeStamps() {
|
||||
if (!loadNativeLibrary()) {
|
||||
fallbackLogger.log(
|
||||
Level.WARNING, "Cannot enable log timestamps because native lib not loaded.");
|
||||
return;
|
||||
}
|
||||
nativeEnableLogTimeStamps();
|
||||
}
|
||||
|
||||
// TODO(solenberg): Remove once dependent projects updated.
|
||||
@Deprecated
|
||||
public static void enableTracing(String path, EnumSet<TraceLevel> levels) {
|
||||
}
|
||||
public static void enableTracing(String path, EnumSet<TraceLevel> levels) {}
|
||||
|
||||
// Enable diagnostic logging for messages of |severity| to the platform debug
|
||||
// output. On Android, the output will be directed to Logcat.
|
||||
// Note: this function starts collecting the output of the LOG() macros.
|
||||
public static synchronized void enableLogToDebugOutput(Severity severity) {
|
||||
if (!loadNativeLibrary()) {
|
||||
fallbackLogger.log(Level.WARNING, "Cannot enable logging because native lib not loaded.");
|
||||
return;
|
||||
}
|
||||
nativeEnableLogToDebugOutput(severity.ordinal());
|
||||
loggingEnabled = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user