Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Unified Diff: webrtc/base/java/src/org/webrtc/Logging.java

Issue 2816753002: Revert of Android Logging.java: Load native library only when needed (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | webrtc/sdk/android/api/org/webrtc/FileVideoCapturer.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 64c405b52ef54e1319321b5816548f1854b05057..736dcf0d4329443b4cdd7398913a92b2e6ca815b 100644
--- a/webrtc/base/java/src/org/webrtc/Logging.java
+++ b/webrtc/base/java/src/org/webrtc/Logging.java
@@ -16,40 +16,23 @@
import java.util.logging.Level;
import java.util.logging.Logger;
-/**
- * Java wrapper for WebRTC logging. Logging defaults to java.util.logging.Logger, but will switch to
- * native logging (rtc::LogMessage) if one of the following static functions are called from the
- * app:
- * - Logging.enableLogThreads
- * - Logging.enableLogTimeStamps
- * - Logging.enableTracing
- * - Logging.enableLogToDebugOutput
- * Using native logging requires the presence of the jingle_peerconnection_so library.
- */
+/** Java wrapper for WebRTC logging. */
public class Logging {
- private static final Logger fallbackLogger = createFallbackLogger();
+ private static final Logger fallbackLogger = Logger.getLogger("org.webrtc.Logging");
private static volatile boolean tracingEnabled;
private static volatile boolean loggingEnabled;
- private static enum NativeLibStatus { UNINITIALIZED, LOADED, FAILED }
- private static volatile NativeLibStatus nativeLibStatus;
+ private static volatile boolean nativeLibLoaded;
- private static Logger createFallbackLogger() {
- final Logger fallbackLogger = Logger.getLogger("org.webrtc.Logging");
- fallbackLogger.setLevel(Level.ALL);
- return fallbackLogger;
- }
+ static {
+ try {
+ System.loadLibrary("jingle_peerconnection_so");
+ nativeLibLoaded = true;
+ } catch (UnsatisfiedLinkError t) {
+ // If native logging is unavailable, log to system log.
+ fallbackLogger.setLevel(Level.ALL);
- 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);
- }
+ fallbackLogger.log(Level.WARNING, "Failed to load jingle_peerconnection_so: ", t);
}
- return nativeLibStatus == NativeLibStatus.LOADED;
}
// Keep in sync with webrtc/common_types.h:TraceLevel.
@@ -80,7 +63,7 @@
public enum Severity { LS_SENSITIVE, LS_VERBOSE, LS_INFO, LS_WARNING, LS_ERROR, LS_NONE }
public static void enableLogThreads() {
- if (!loadNativeLibrary()) {
+ if (!nativeLibLoaded) {
fallbackLogger.log(Level.WARNING, "Cannot enable log thread because native lib not loaded.");
return;
}
@@ -88,7 +71,7 @@
}
public static void enableLogTimeStamps() {
- if (!loadNativeLibrary()) {
+ if (!nativeLibLoaded) {
fallbackLogger.log(
Level.WARNING, "Cannot enable log timestamps because native lib not loaded.");
return;
@@ -100,7 +83,7 @@
// On Android, use "logcat:" for |path| to send output there.
// Note: this function controls the output of the WEBRTC_TRACE() macros.
public static synchronized void enableTracing(String path, EnumSet<TraceLevel> levels) {
- if (!loadNativeLibrary()) {
+ if (!nativeLibLoaded) {
fallbackLogger.log(Level.WARNING, "Cannot enable tracing because native lib not loaded.");
return;
}
@@ -120,7 +103,7 @@
// 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()) {
+ if (!nativeLibLoaded) {
fallbackLogger.log(Level.WARNING, "Cannot enable logging because native lib not loaded.");
return;
}
« no previous file with comments | « no previous file | webrtc/sdk/android/api/org/webrtc/FileVideoCapturer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698