X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FCache.java;h=6e44b0c44671cfaed65cb5773dffb322211b5c70;hb=af259f508805faf2da90585ee9a67cd7853bf5aa;hp=8418d6888e68cc006137767ea0390e3af07d030d;hpb=a84906104415e9e65713af39a225090ebd7beff0;p=jalview.git diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 8418d68..6e44b0c 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -20,16 +20,6 @@ */ package jalview.bin; -import jalview.datamodel.PDBEntry; -import jalview.gui.UserDefinedColours; -import jalview.schemes.ColourSchemeLoader; -import jalview.schemes.ColourSchemes; -import jalview.schemes.UserColourScheme; -import jalview.structure.StructureImportSettings; -import jalview.urls.IdOrgSettings; -import jalview.util.ColorUtils; -import jalview.ws.sifts.SiftsSettings; - import java.awt.Color; import java.io.BufferedReader; import java.io.File; @@ -37,6 +27,8 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.io.StringWriter; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Collections; @@ -46,12 +38,26 @@ import java.util.Locale; import java.util.Properties; import java.util.StringTokenizer; import java.util.TreeSet; +import java.util.regex.Pattern; + +import javax.swing.LookAndFeel; +import javax.swing.UIManager; import org.apache.log4j.ConsoleAppender; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.apache.log4j.SimpleLayout; +import jalview.datamodel.PDBEntry; +import jalview.gui.UserDefinedColours; +import jalview.schemes.ColourSchemeLoader; +import jalview.schemes.ColourSchemes; +import jalview.schemes.UserColourScheme; +import jalview.structure.StructureImportSettings; +import jalview.urls.IdOrgSettings; +import jalview.util.ColorUtils; +import jalview.ws.sifts.SiftsSettings; + /** * Stores and retrieves Jalview Application Properties Lists and fields within * list entries are separated by '|' symbols unless otherwise stated (|) clauses @@ -435,8 +441,8 @@ public class Cache String jnlpVersion = System.getProperty("jalview.version"); - // jnlpVersion will be null if a latest version check for the channel needs to - // be done + // jnlpVersion will be null if a latest version check for the channel needs + // to be done // Dont do this check if running in headless mode if (jnlpVersion == null && getDefault("VERSION_CHECK", true) @@ -555,8 +561,8 @@ public class Cache new BuildDetails(codeVersion, null, codeInstallation); if (printV && reportVersion) { - System.out - .println("Jalview Version: " + codeVersion + codeInstallation); + System.out.println( + "Jalview Version: " + codeVersion + codeInstallation); } } @@ -1075,31 +1081,73 @@ public class Cache } /** + * Initial logging information helper for various versions output + * + * @param prefix + * @param value + * @param defaultValue + */ + private static void appendIfNotNull(StringBuilder sb, String prefix, + String value, String suffix, String defaultValue) + { + if (value == null && defaultValue == null) + { + return; + } + String line = prefix + (value != null ? value : defaultValue) + suffix; + sb.append(line); + } + + /** * * @return Jalview version, build details and JVM platform version for console */ public static String getVersionDetailsForConsole() { - return "Jalview Version: " - + jalview.bin.Cache.getDefault("VERSION", "TEST") - + "\n" + "Jalview Installation: " - + jalview.bin.Cache.getDefault("INSTALLATION", - "unknown") - + "\n" + "Build Date: " - + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown") - + "\n" + "Java version: " - + System.getProperty("java.version") + "\n" - + System.getProperty("os.arch") + " " - + System.getProperty("os.name") + " " - + System.getProperty("os.version") - + (jalview.bin.Cache.getDefault("VERSION", "TEST") - .equals("DEVELOPMENT") - ? "\nGetdown appdir: " + System.getProperty("getdownappdir") + "\nJava path: " - + System.getProperty( - "java.home") - + File.separator + "bin" - + File.separator + "java" - : ""); + StringBuilder sb = new StringBuilder(); + sb.append("Jalview Version: "); + sb.append(jalview.bin.Cache.getDefault("VERSION", "TEST")); + sb.append("\n"); + sb.append("Jalview Installation: "); + sb.append(jalview.bin.Cache.getDefault("INSTALLATION", "unknown")); + sb.append("\n"); + sb.append("Build Date: "); + sb.append(jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")); + sb.append("\n"); + sb.append("Java version: "); + sb.append(System.getProperty("java.version")); + sb.append("\n"); + sb.append(System.getProperty("os.arch")); + sb.append(" "); + sb.append(System.getProperty("os.name")); + sb.append(" "); + sb.append(System.getProperty("os.version")); + sb.append("\n"); + appendIfNotNull(sb, "Install4j version: ", + System.getProperty("sys.install4jVersion"), "\n", null); + appendIfNotNull(sb, "Install4j template version: ", + System.getProperty("installer_template_version"), "\n", null); + appendIfNotNull(sb, "Launcher version: ", + System.getProperty("launcher_version"), "\n", null); + LookAndFeel laf = UIManager.getLookAndFeel(); + String lafName = laf == null ? "Not obtained" : laf.getName(); + String lafClass = laf == null ? "unknown" : laf.getClass().getName(); + sb.append("LookAndFeel: "); + sb.append(lafName); + sb.append(" ("); + sb.append(lafClass); + sb.append(")\n"); + // Not displayed in release version ( determined by possible version number + // regex 9[9.]*9[.-_a9]* ) + if (Pattern.matches("^\\d[\\d\\.]*\\d[\\.\\-\\w]*$", + jalview.bin.Cache.getDefault("VERSION", "TEST"))) + { + appendIfNotNull(sb, "Getdown appdir: ", + System.getProperty("getdownappdir"), "\n", null); + appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"), + "\n", "unknown"); + } + return sb.toString(); } /** @@ -1112,4 +1160,12 @@ public class Cache // eg 'built from Source' or update channel return jalview.bin.Cache.getDefault("INSTALLATION", "unknown"); } + + public static String getStackTraceString(Throwable t) + { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + t.printStackTrace(pw); + return sw.toString(); + } }