[libbluray-devel] Capture on-disc BD-J applets debug output
hpi1
git at videolan.org
Wed Mar 13 10:09:57 CET 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Mar 13 10:48:39 2013 +0200| [185ff964b03a4d6cff95046e7b844db9a0ebc24b] | committer: hpi1
Capture on-disc BD-J applets debug output
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=185ff964b03a4d6cff95046e7b844db9a0ebc24b
---
src/libbluray/bdj/java/org/videolan/Logger.java | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/libbluray/bdj/java/org/videolan/Logger.java b/src/libbluray/bdj/java/org/videolan/Logger.java
index 12b8437..e5988b7 100644
--- a/src/libbluray/bdj/java/org/videolan/Logger.java
+++ b/src/libbluray/bdj/java/org/videolan/Logger.java
@@ -19,6 +19,8 @@
package org.videolan;
+import java.io.PrintStream;
+
public class Logger {
static {
String prop;
@@ -26,6 +28,11 @@ public class Logger {
use_throw = false;
use_trace = false;
+ // capture stdout and stderr from on-disc applets
+ // (those produce useful debug information sometimes)
+ System.setOut(createCapture(System.out, false));
+ System.setErr(createCapture(System.err, true));
+
prop = System.getProperty("debug.unimplemented.throw");
if (prop != null && prop.equalsIgnoreCase("YES")) {
use_throw = true;
@@ -63,6 +70,17 @@ public class Logger {
return new Location();
}
+ private static PrintStream createCapture(final PrintStream printStream, final boolean error) {
+ return new PrintStream(printStream) {
+ public void print(final String string) {
+ Logger.log(error, string);
+ }
+ public void println(final String string) {
+ Logger.log(error, string);
+ }
+ };
+ }
+
public static Logger getLogger(String name) {
return new Logger(name);
}
@@ -76,7 +94,6 @@ public class Logger {
private static void log(boolean error, String cls, String msg) {
logN(error, cls, 0, msg);
}
-
private static void log(boolean error, String msg) {
Location l = getLocation(3);
logN(error, l.file + ":" + l.cls + "." + l.func, l.line, msg);
More information about the libbluray-devel
mailing list