if openrocket.debug then redirect stderr to log.debug().
This commit is contained in:
parent
bc2e759d86
commit
003e6c35f1
@ -0,0 +1,42 @@
|
|||||||
|
package net.sf.openrocket.gui.figure3d;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
import net.sf.openrocket.logging.LogHelper;
|
||||||
|
import net.sf.openrocket.startup.Application;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects system err into OpenRocket's log.debug() if openrocket.debug is enabled.
|
||||||
|
* This lets me capture JOGL debug as log events, which can be included in error reports etc.
|
||||||
|
* I wish I could get the JOGL debug log on a separate printstream, so I do not have to take
|
||||||
|
* over all of ERR.
|
||||||
|
*
|
||||||
|
* @author bkuker
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
final class JoglDebugAdaptor {
|
||||||
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
|
final static void plumbJoglDebug() {
|
||||||
|
if (RocketFigure3d.is3dEnabled() && System.getProperty("openrocket.debug") != null) {
|
||||||
|
System.setProperty("jogl.debug", "all");
|
||||||
|
|
||||||
|
System.setErr(new PrintStream(new OutputStream() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void write(int b) throws IOException {
|
||||||
|
if (b == '\r' || b == '\n') {
|
||||||
|
if (sb.toString().trim().length() > 0)
|
||||||
|
log.debug(sb.toString());
|
||||||
|
sb = new StringBuilder();
|
||||||
|
} else {
|
||||||
|
sb.append((char) b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -52,6 +52,8 @@ public class RocketFigure3d extends JPanel implements GLEventListener {
|
|||||||
private static final LogHelper log = Application.getLogger();
|
private static final LogHelper log = Application.getLogger();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
JoglDebugAdaptor.plumbJoglDebug();
|
||||||
|
|
||||||
//this allows the GL canvas and things like the motor selection
|
//this allows the GL canvas and things like the motor selection
|
||||||
//drop down to z-order themselves.
|
//drop down to z-order themselves.
|
||||||
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user