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

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

Issue 1354803002: Add system log fallback when native logging is unavailable. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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 d5c1690cbc340552070ce7ea4e68cf377cf42b42..107e55fe556a13aef20453370a5a0c632763643e 100644
--- a/webrtc/base/java/src/org/webrtc/Logging.java
+++ b/webrtc/base/java/src/org/webrtc/Logging.java
@@ -13,13 +13,26 @@ package org.webrtc;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.EnumSet;
+import java.util.logging.ConsoleHandler;
+import java.util.logging.SimpleFormatter;
+import java.util.logging.Handler;
+import java.util.logging.Logger;
+import java.util.logging.Level;
/** Java wrapper for WebRTC logging. */
public class Logging {
+ private static final Logger fallbackLogger = Logger.getLogger("org.webrtc.Logging");
+
static {
try {
System.loadLibrary("jingle_peerconnection_so");
} catch (Throwable t) {
+ // If native logging is unavailable, log to system log.
+ ConsoleHandler consolehandler = new ConsoleHandler();
+ consolehandler.setFormatter(new SimpleFormatter());
+ consolehandler.setLevel(Level.ALL);
+ fallbackLogger.addHandler(consolehandler);
+ fallbackLogger.setLevel(Level.FINE);
}
}
@@ -75,6 +88,22 @@ public class Logging {
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;
+ }
+ fallbackLogger.log(level, tag + ": " + 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