From b5377ca66b9fb81ac28cab308c326798b95a510d Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 29 May 2019 14:09:17 -0700 Subject: [PATCH] Use a `debug` system property to control debugging. When set, it disables stdout/stderr redirection and uses java.exe on Windows so that a console window is shown with output from the launched app. This removes the use of a debug.txt file. --- .../java/com/threerings/getdown/data/Application.java | 7 +------ .../main/java/com/threerings/getdown/data/SysProps.java | 8 ++++++++ .../java/com/threerings/getdown/launcher/GetdownApp.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/threerings/getdown/data/Application.java b/core/src/main/java/com/threerings/getdown/data/Application.java index 04bd3c3..e3cdd82 100644 --- a/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/core/src/main/java/com/threerings/getdown/data/Application.java @@ -784,10 +784,6 @@ public class Application // extract some info used to configure our child process on macOS _dockName = config.getString("ui.name"); _dockIconPath = config.getString("ui.mac_dock_icon", "../desktop.icns"); - - // look for a debug.txt file which causes us to run in java.exe on Windows so that we can - // obtain a thread dump of the running JVM - _windebug = getLocalPath("debug.txt").exists(); } /** @@ -967,7 +963,7 @@ public class Application ArrayList args = new ArrayList<>(); // reconstruct the path to the JVM - args.add(LaunchUtil.getJVMBinaryPath(_javaLocalDir, _windebug || optimum)); + args.add(LaunchUtil.getJVMBinaryPath(_javaLocalDir, SysProps.debug() || optimum)); // check whether we're using -jar mode or -classpath mode boolean dashJarMode = MANIFEST_CLASS.equals(_class); @@ -1737,7 +1733,6 @@ public class Application protected String _dockName; protected String _dockIconPath; protected boolean _strictComments; - protected boolean _windebug; protected boolean _allowOffline; protected int _maxConcDownloads; diff --git a/core/src/main/java/com/threerings/getdown/data/SysProps.java b/core/src/main/java/com/threerings/getdown/data/SysProps.java index 1de9cd4..b36d400 100644 --- a/core/src/main/java/com/threerings/getdown/data/SysProps.java +++ b/core/src/main/java/com/threerings/getdown/data/SysProps.java @@ -40,6 +40,14 @@ public final class SysProps return System.getProperty("no_log_redir") != null; } + /** Used to debug Getdown's launching of an app. When set, it disables redirection of stdout + * and stderr into a log file, and on Windows it uses {@code java.exe} to launch the app so + * that its console output can be observed. + * Usage: {@code -Ddebug}. */ + public static boolean debug () { + return System.getProperty("debug") != null; + } + /** Overrides the domain on {@code appbase}. Usage: {@code -Dappbase_domain=foo}. */ public static String appbaseDomain () { return System.getProperty("appbase_domain"); diff --git a/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java b/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java index 964d816..3859f6a 100644 --- a/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java +++ b/launcher/src/main/java/com/threerings/getdown/launcher/GetdownApp.java @@ -66,7 +66,7 @@ public class GetdownApp } // pipe our output into a file in the application directory - if (!SysProps.noLogRedir()) { + if (!SysProps.noLogRedir() && !SysProps.debug()) { File logFile = new File(envc.appDir, "launcher.log"); try { PrintStream logOut = new PrintStream(