X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=osgi%2Fruntime%2Forg.argeo.osgi.boot%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fosgi%2Fboot%2FOsgiBootUtils.java;h=fa3ecc2b10ca2dd99951a9573b24c991bd270143;hb=b799066b80eefac9d6297aff33e95fcdeb1923c3;hp=a9067a213c04e912985fb139651db012c4b3ff3b;hpb=1b452a434924d7628c7b2eace3c5df8e62cdea1c;p=lgpl%2Fargeo-commons.git diff --git a/osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBootUtils.java b/osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBootUtils.java index a9067a213..fa3ecc2b1 100644 --- a/osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBootUtils.java +++ b/osgi/runtime/org.argeo.osgi.boot/src/main/java/org/argeo/osgi/boot/OsgiBootUtils.java @@ -16,33 +16,43 @@ package org.argeo.osgi.boot; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** Utilities, mostly related to logging. */ public class OsgiBootUtils { + /** ISO8601 (as per log4j) and difference to UTC */ + private static DateFormat dateFormat = new SimpleDateFormat( + "yyyy-MM-dd HH:mm:ss,SSS Z"); public static void info(Object obj) { - System.out.println("# OSGiBOOT # " + obj); + System.out.println("# OSGiBOOT # " + dateFormat.format(new Date()) + + " # " + obj); } public static void debug(Object obj) { - System.out.println("# OSGiBOOT DBG # " + obj); + System.out.println("# OSGiBOOT DBG # " + dateFormat.format(new Date()) + + " # " + obj); } public static void warn(Object obj) { - System.out.println("# OSGiBOOT WARN # " + obj); - // Because of a weird bug under Windows when starting it in a forked VM - // if (System.getProperty("os.name").contains("Windows")) - // System.out.println("# WARN " + obj); - // else - // System.err.println("# WARN " + obj); + System.out.println("# OSGiBOOT WARN # " + dateFormat.format(new Date()) + + " # " + obj); } - //FIXE: returns null when defaultValue is "" + /** + * Gets a property value + * + * @return null when defaultValue is "" + */ public static String getProperty(String name, String defaultValue) { final String value; if (defaultValue != null) value = System.getProperty(name, defaultValue); else value = System.getProperty(name); - + if (value == null || value.equals("")) return null; else @@ -53,36 +63,4 @@ public class OsgiBootUtils { return getProperty(name, null); } - public static String getPropertyCompat(String name, String oldName) { - return getPropertyCompat(name, oldName, null); - } - - public static String getPropertyCompat(String name, String oldName, - String defaultValue) { - String res = null; - - if (defaultValue != null) { - res = getProperty(name, defaultValue); - if (res.equals(defaultValue)) { - res = getProperty(oldName, defaultValue); - if (!res.equals(defaultValue)) - warnDeprecated(name, oldName); - } - } else { - res = getProperty(name, null); - if (res == null) { - res = getProperty(oldName, null); - if (res != null) - warnDeprecated(name, oldName); - } - } - return res; - } - - public static void warnDeprecated(String name, String oldName) { - warn("Property '" + oldName - + "' is deprecated and will be removed soon, use '" + name - + "' instead."); - } - }