diff options
| author | ogattaz <olivier@gattaz.com> | 2014-07-24 15:37:48 +0200 |
|---|---|---|
| committer | ogattaz <olivier@gattaz.com> | 2014-07-24 15:37:48 +0200 |
| commit | 650b3ce0a90c4b764f94f46ea8c8dfc5e14a4469 (patch) | |
| tree | d7ec46b452f80f24fc5048c25ae2e8954aa1eac6 /src/main/java/com/c2kernel | |
| parent | 6244fae0aeb2e0986593387ed8fece48fba847fd (diff) | |
Modification of the management of the Logger during the reading of the
starting arguments
Diffstat (limited to 'src/main/java/com/c2kernel')
| -rw-r--r-- | src/main/java/com/c2kernel/process/AbstractMain.java | 75 |
1 files changed, 65 insertions, 10 deletions
diff --git a/src/main/java/com/c2kernel/process/AbstractMain.java b/src/main/java/com/c2kernel/process/AbstractMain.java index 202ae9e..ad21b78 100644 --- a/src/main/java/com/c2kernel/process/AbstractMain.java +++ b/src/main/java/com/c2kernel/process/AbstractMain.java @@ -30,11 +30,55 @@ abstract public class AbstractMain {
public static boolean isServer = false;
private static ShutdownHandler shutdownHandler;
-
-
- /**************************************************************************
- * reading and setting input paramaters
- **************************************************************************/
+
+ public static String MAIN_ARG_NONEWLOGSTREAM = "noNewLogStream";
+ public static String MAIN_ARG_CONFIG = "config";
+ public static String MAIN_ARG_LOGLEVEL = "logLevel";
+ public static String MAIN_ARG_LOGFILE = "logFile";
+ public static String MAIN_ARG_CONNECT = "connect";
+ public static String MAIN_ARG_HELP = "help";
+ public static String MAIN_ARG_HELPSHORT = "h";
+
+ /**
+ *
+ * -noNewLogStream: if present no new Logstream is added to the logger (
+ * considers that the Logger is already configured)
+ *
+ * @return help informations
+ */
+ public static String usageHelp() {
+
+ return "USAGE: com.c2kernel.process.AbstractMain \n"
+ + " -config <server/client config file> \n"
+ + " [-connect <LC connect file> ] (or LocalCentre in conf)\n"
+ + " [-h] [-help] \n" + " [-logLevel 0-19] \n"
+ + " [-logFile <path to log file>]"
+ + " [-noNewLogStream ]";
+ }
+
+
+
+ /**************************************************************************
+ * reading and setting input paramaters
+ **************************************************************************
+ *
+ * Known arguments :
+ * <ul>
+ * <li>logLevel: the log level 0-9 (+10 to have time, +20 to have only one level)</li>
+ * <li>logFile: the full path of the target log file. if none, the Logstream is the stdOut</li>
+ * <li>noNewLogStream: if present no new Logstream is added to the logger (
+ * considers that the Logger is already configured)</li>
+ *
+ * <li>config</li>
+ * <li>connect</li>
+ * <li>LocalCentre</li>
+ * </ul>
+ *
+ *
+ * @param args
+ * @return
+ * @throws BadArgumentsException
+ */
public static Properties readC2KArgs( String[] args ) throws BadArgumentsException {
Properties c2kProps;
Properties argProps = new Properties();
@@ -66,13 +110,24 @@ abstract public class AbstractMain throw new BadArgumentsException("Logfile "+argProps.getProperty("logFile")+" cannot be created");
}
- // Set up log stream
- if (argProps.containsKey("logLevel"))
- logLevel = Integer.parseInt(argProps.getProperty("logLevel"));
- Logger.addLogStream(logStream, logLevel);
- // Dump params if log high enough
+ // if the optional arg "noNewLogStream" isn't present => add a
+ // new LogStream
+ boolean wMustAddNewLogStream = !argProps.contains(MAIN_ARG_NONEWLOGSTREAM);
+ if (wMustAddNewLogStream) {
+
+ // Set up log stream
+ if (argProps.containsKey("logLevel"))
+ logLevel = Integer.parseInt(argProps.getProperty("logLevel"));
+
+ Logger.addLogStream(logStream, logLevel);
+ }
+ Logger.msg(0, String.format(
+ "AbstractMain.readC2KArgs(): New logStream added = [%b]",
+ wMustAddNewLogStream));
+
+ // Dump params if log high enough
if (Logger.doLog(3)) for (Enumeration<?> e = argProps.propertyNames(); e.hasMoreElements();) {
String next = (String)e.nextElement();
System.out.println("AbstractMain: Param "+next+": "+argProps.getProperty(next));
|
