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

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

Issue 2110853003: Separate the JNI function that controls logging levels into two. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Separated the tracing/logging enabled flags Created 4 years, 6 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
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 ea1bca3bdb18fd99a6885226254531acd647dcd7..684e5bc5b20b762f57f38c295055aa467fc31e42 100644
--- a/webrtc/base/java/src/org/webrtc/Logging.java
+++ b/webrtc/base/java/src/org/webrtc/Logging.java
@@ -20,6 +20,7 @@ import java.util.logging.Level;
public class Logging {
private static final Logger fallbackLogger = Logger.getLogger("org.webrtc.Logging");
private static volatile boolean tracingEnabled;
+ private static volatile boolean loggingEnabled;
private static volatile boolean nativeLibLoaded;
static {
@@ -60,7 +61,7 @@ public class Logging {
// Keep in sync with webrtc/base/logging.h:LoggingSeverity.
public enum Severity {
- LS_SENSITIVE, LS_VERBOSE, LS_INFO, LS_WARNING, LS_ERROR,
+ LS_SENSITIVE, LS_VERBOSE, LS_INFO, LS_WARNING, LS_ERROR, LS_NONE
};
public static void enableLogThreads() {
@@ -80,10 +81,11 @@ public class Logging {
nativeEnableLogTimeStamps();
}
- // Enable tracing to |path| of messages of |levels| and |severity|.
+ // Enable tracing to |path| of messages of |levels|.
// 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, Severity severity) {
+ String path, EnumSet<TraceLevel> levels) {
if (!nativeLibLoaded) {
fallbackLogger.log(Level.WARNING, "Cannot enable tracing because native lib not loaded.");
return;
@@ -96,12 +98,24 @@ public class Logging {
for (TraceLevel level : levels) {
nativeLevel |= level.level;
}
- nativeEnableTracing(path, nativeLevel, severity.ordinal());
+ nativeEnableTracing(path, nativeLevel);
tracingEnabled = true;
}
+ // 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 (!nativeLibLoaded) {
+ fallbackLogger.log(Level.WARNING, "Cannot enable logging because native lib not loaded.");
+ return;
+ }
+ nativeEnableLogToDebugOutput(severity.ordinal());
+ loggingEnabled = true;
+ }
+
public static void log(Severity severity, String tag, String message) {
- if (tracingEnabled) {
+ if (loggingEnabled) {
nativeLog(severity.ordinal(), tag, message);
return;
}
@@ -165,7 +179,8 @@ public class Logging {
}
private static native void nativeEnableTracing(
- String path, int nativeLevels, int nativeSeverity);
+ String path, int nativeLevels);
+ private static native void nativeEnableLogToDebugOutput(int nativeSeverity);
private static native void nativeEnableLogThreads();
private static native void nativeEnableLogTimeStamps();
private static native void nativeLog(int severity, String tag, String message);
« no previous file with comments | « webrtc/api/java/jni/peerconnection_jni.cc ('k') | webrtc/examples/androidapp/src/org/appspot/apprtc/PeerConnectionClient.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698