X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FCache.java;h=85d23dffdeb016685027c6fed7d2c47c2dc0a8f9;hb=1d293bcfa2988c7fe62a48efd663074b9adb4eb3;hp=9e28f5d17ca82cf667d671e710d2bd68cd8e4ddc;hpb=17e4ea278bc9a5fb280db1252ce78b7a295215f5;p=jalview.git diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 9e28f5d..85d23df 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -38,6 +38,7 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; +import java.net.URL; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Collections; @@ -312,6 +313,9 @@ public class Cache // lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller"); // lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level", // Level.INFO.toString()))); + // we shouldn't need to do this + org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.INFO); + jalview.bin.Cache.log.setLevel(Level.toLevel(Cache .getDefault("logs.Jalview.level", Level.INFO.toString()))); // laxis.addAppender(ap); @@ -396,13 +400,13 @@ public class Cache } // LOAD THE AUTHORS FROM THE authors.props file - String authorDetails = resolveResourceURLFor("authors.props"); + String authorDetails = resolveResourceURLFor("/authors.props"); try { if (authorDetails != null) { - java.net.URL localJarFileURL = new java.net.URL(authorDetails); + URL localJarFileURL = new URL(authorDetails); InputStream in = localJarFileURL.openStream(); applicationProperties.load(in); in.close(); @@ -542,7 +546,8 @@ public class Cache url = Cache.class.getResource(resourcePath).toString(); } catch (Exception ex) { - + System.err.println("Failed to resolve resource " + resourcePath + ": " + + ex.getMessage()); } } else @@ -556,17 +561,16 @@ public class Cache public static void loadBuildProperties(boolean reportVersion) { String codeInstallation = getProperty("INSTALLATION"); - boolean printV = codeInstallation == null; + boolean printVersion = codeInstallation == null; - // FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar + /* + * read build properties - from the Jalview jar for a Java distribution, + * or from codebase file in test or JalviewJS context + */ try { - String buildDetails = "jar:".concat(Cache.class.getProtectionDomain() - .getCodeSource().getLocation().toString() - .concat("!/.build_properties")); - - java.net.URL localJarFileURL = new java.net.URL(buildDetails); - + String buildDetails = resolveResourceURLFor("/.build_properties"); + URL localJarFileURL = new URL(buildDetails); InputStream in = localJarFileURL.openStream(); applicationProperties.load(in); in.close(); @@ -590,7 +594,7 @@ public class Cache } setProperty("VERSION", codeVersion); new BuildDetails(codeVersion, null, codeInstallation); - if (printV && reportVersion) + if (printVersion && reportVersion) { System.out .println("Jalview Version: " + codeVersion + codeInstallation); @@ -1113,31 +1117,54 @@ 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: " + jalview.bin.Cache.getDefault("VERSION", "TEST")); + sb.append("\n"); + sb.append("Jalview Installation: " + + jalview.bin.Cache.getDefault("INSTALLATION", "unknown")); + sb.append("\n"); + sb.append("Build Date: " + jalview.bin.Cache.getDefault("BUILD_DATE", "unknown")); + sb.append("\n"); + sb.append("Java version: " + System.getProperty("java.version")); + sb.append("\n"); + sb.append(System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + 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); + if (jalview.bin.Cache.getDefault("VERSION", "TEST").equals("DEVELOPMENT")) { + appendIfNotNull(sb, "Getdown appdir: ", + System.getProperty("getdownappdir"), "\n", null); + appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"), + "\n", "unknown"); + } + return sb.toString(); } /**