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

Unified Diff: talk/app/webrtc/java/src/org/webrtc/Logging.java

Issue 1338033003: Log to webrtc logging stream from java code. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: not lose tag 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
Index: talk/app/webrtc/java/src/org/webrtc/Logging.java
diff --git a/talk/app/webrtc/java/src/org/webrtc/Logging.java b/talk/app/webrtc/java/src/org/webrtc/Logging.java
index 75f758978333561b16117413a993457992f4974e..58da68b7c1a3fa9fb2e206cbaaa0f8f25c80a130 100644
--- a/talk/app/webrtc/java/src/org/webrtc/Logging.java
+++ b/talk/app/webrtc/java/src/org/webrtc/Logging.java
@@ -27,6 +27,9 @@
package org.webrtc;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.nio.charset.Charset;
import java.util.EnumSet;
/** Java wrapper for WebRTC & libjingle logging. */
@@ -84,12 +87,47 @@ public class Logging {
}
public static void log(Severity severity, String tag, String message) {
- nativeLog(severity.ordinal(), tag + ": " + message);
+ nativeLog(severity.ordinal(), tag, message);
+ }
+
+ public static void d(String tag, String message) {
+ log(Severity.LS_INFO, tag, message);
+ }
+
+ public static void e(String tag, String message) {
+ log(Severity.LS_ERROR, tag, message);
+ }
+
+ public static void w(String tag, String message) {
+ log(Severity.LS_WARNING, tag, message);
+ }
+
+ public static void e(String tag, String message, Throwable e) {
+ log(Severity.LS_ERROR, tag, message);
+ log(Severity.LS_ERROR, tag, e.toString());
+ log(Severity.LS_ERROR, tag, getStackTraceAsString(e));
+ }
+
+ public static void w(String tag, String message, Throwable e) {
+ log(Severity.LS_WARNING, tag, message);
+ log(Severity.LS_WARNING, tag, e.toString());
+ log(Severity.LS_WARNING, tag, getStackTraceAsString(e));
+ }
+
+ public static void v(String tag, String message) {
+ log(Severity.LS_VERBOSE, tag, message);
+ }
+
+ private static String getStackTraceAsString(Throwable e) {
AlexG 2015/09/14 20:12:33 May be mimic Android implementation here (getStack
jiayl2 2015/09/14 20:54:38 Done.
+ ByteArrayOutputStream ostream = new ByteArrayOutputStream();
+ PrintStream pstream = new PrintStream(ostream);
+ e.printStackTrace(pstream);
+ return ostream.toString();
}
private static native void nativeEnableTracing(
String path, int nativeLevels, int nativeSeverity);
private static native void nativeEnableLogThreads();
private static native void nativeEnableLogTimeStamps();
- private static native void nativeLog(int severity, String message);
+ private static native void nativeLog(int severity, String tag, String message);
}

Powered by Google App Engine
This is Rietveld 408576698