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

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

Issue 1368053002: Fallback to system log when webrtc tracing not enabled. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: synchronize Created 5 years, 3 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 | no next file » | 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 751a5c4f9cd92e302755e437c0844dea0759fa9f..aea4ffb23ed57a50d151409c52ce81b4cb03eaa4 100644
--- a/webrtc/base/java/src/org/webrtc/Logging.java
+++ b/webrtc/base/java/src/org/webrtc/Logging.java
@@ -19,6 +19,7 @@ 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;
static {
try {
@@ -68,36 +69,46 @@ public class Logging {
// Enable tracing to |path| of messages of |levels| and |severity|.
// On Android, use "logcat:" for |path| to send output there.
- public static void enableTracing(
+ public static synchronized void enableTracing(
String path, EnumSet<TraceLevel> levels, Severity severity) {
+ if (tracingEnabled) {
+ return;
+ }
int nativeLevel = 0;
for (TraceLevel level : levels) {
nativeLevel |= level.level;
}
nativeEnableTracing(path, nativeLevel, severity.ordinal());
+ tracingEnabled = true;
}
public static void log(Severity severity, String tag, String message) {
- try {
- nativeLog(severity.ordinal(), tag, message);
- } catch (Throwable t) {
- Level level;
- switch (severity) {
- case LS_ERROR:
- level = Level.SEVERE;
- break;
- case LS_WARNING:
- level = Level.WARNING;
- break;
- case LS_INFO:
- level = Level.INFO;
- break;
- default:
- level = Level.FINE;
- break;
+ if (tracingEnabled) {
+ try {
+ nativeLog(severity.ordinal(), tag, message);
+ return;
+ } catch (Throwable t) {
+ // Don't log the error to avoid spamming.
}
- fallbackLogger.log(level, tag + ": " + message);
}
+
+ // Fallback to system log.
+ Level level;
+ switch (severity) {
+ case LS_ERROR:
+ level = Level.SEVERE;
+ break;
+ case LS_WARNING:
+ level = Level.WARNING;
+ break;
+ case LS_INFO:
+ level = Level.INFO;
+ break;
+ default:
+ level = Level.FINE;
+ break;
+ }
+ fallbackLogger.log(level, tag + ": " + message);
}
public static void d(String tag, String message) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698