From a0a1c839648e4cfceda9f6dad38c4fc6284cd0bc Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Wed, 19 Oct 2016 11:21:46 +1100 Subject: [PATCH] Improve logging modules and listing #984 Use ERROR instead of WARN for fatal start problems improved log formatting --- .../main/java/org/eclipse/jetty/start/Main.java | 8 ++++---- .../java/org/eclipse/jetty/start/Modules.java | 6 +++--- .../java/org/eclipse/jetty/start/StartLog.java | 15 ++++++++++----- .../usecases/barebones.alreadyEnabled.assert.txt | 2 +- .../empty.addToStartCreateStartd.assert.txt | 2 +- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java index 39c7bbabfa4..1193528b78a 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Main.java @@ -76,7 +76,7 @@ public class Main } catch (UsageException e) { - StartLog.warn(e.getMessage()); + StartLog.error(e.getMessage()); usageExit(e.getCause(),e.getExitCode(),test); } catch (Throwable e) @@ -197,7 +197,7 @@ public class Main } catch (ClassNotFoundException e) { - StartLog.warn("Nothing to start, exiting ..."); + StartLog.error("Nothing to start, exiting ..."); StartLog.debug(e); usageExit(ERR_INVOKE_MAIN); return; @@ -510,7 +510,7 @@ public class Main { if (port <= 0) { - StartLog.warn("STOP.PORT system property must be specified"); + StartLog.error("STOP.PORT system property must be specified"); } if (key == null) { @@ -616,7 +616,7 @@ public class Main } catch (UsageException e) { - StartLog.warn(e.getMessage()); + StartLog.error(e.getMessage()); usageExit(e.getCause(),e.getExitCode(),startupArgs.isTestingModeEnabled()); } catch (Throwable e) diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java index d4a25087363..1143b2e809d 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/Modules.java @@ -363,7 +363,7 @@ public class Modules implements Iterable if (dftProvider.isPresent()) enable(newlyEnabled,dftProvider.get(),"transitive provider of "+dependsOn+" for "+module.getName(),true); else if (StartLog.isDebugEnabled()) - StartLog.debug("Module %s requires %s from one of %s",module,dependsOn,providers); + StartLog.debug("Module %s requires a %s implementation from one of %s",module,dependsOn,providers); } } } @@ -375,7 +375,7 @@ public class Modules implements Iterable { String reason = _deprecated.getProperty(name); if (reason!=null) - StartLog.warn("Deprecated module '%s' is %s",name,reason); + StartLog.warn("Deprecated module '%s': %s",name,reason); } return module; } @@ -405,7 +405,7 @@ public class Modules implements Iterable if (unsatisfied.length()>0) unsatisfied.append(','); unsatisfied.append(m.getName()); - StartLog.warn("Module %s requires %s from one of %s%n",m.getName(),d,providers); + StartLog.error("Module %s requires a `%s` module from one of %s%n",m.getName(),d,providers); } }); }); diff --git a/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java b/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java index 580ebfbe11c..2512756e3ed 100644 --- a/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java +++ b/jetty-start/src/main/java/org/eclipse/jetty/start/StartLog.java @@ -56,7 +56,7 @@ public class StartLog { if (INSTANCE.trace) { - out.printf("TRACE: " + format + "%n",args); + out.printf("TRACE " + format + "%n",args); } } @@ -75,22 +75,27 @@ public class StartLog public static void log(String type, String msg) { - logStream.println(type + ": " + msg); + logStream.printf("%-6s: %s%n",type,msg); } public static void log(String type, String format, Object... args) { - logStream.printf(type + ": " + format + "%n",args); + log(type,String.format(format,args)); } public static void info(String format, Object... args) { - log("INFO ",format,args); + log("INFO",format,args); } public static void warn(String format, Object... args) { - log("WARN ",format,args); + log("WARN",format,args); + } + + public static void error(String format, Object... args) + { + log("ERROR",format,args); } public static void warn(Throwable t) diff --git a/jetty-start/src/test/resources/usecases/barebones.alreadyEnabled.assert.txt b/jetty-start/src/test/resources/usecases/barebones.alreadyEnabled.assert.txt index 9b924722124..a122fc3419d 100644 --- a/jetty-start/src/test/resources/usecases/barebones.alreadyEnabled.assert.txt +++ b/jetty-start/src/test/resources/usecases/barebones.alreadyEnabled.assert.txt @@ -14,4 +14,4 @@ PROP|main.prop=value0 EXISTS|maindir/ EXISTS|start.ini -OUTPUT|INFO : main already enabled by \[\$\{jetty.base}/start.ini] +OUTPUT|INFO : main already enabled by \[\$\{jetty.base}/start.ini] diff --git a/jetty-start/src/test/resources/usecases/empty.addToStartCreateStartd.assert.txt b/jetty-start/src/test/resources/usecases/empty.addToStartCreateStartd.assert.txt index 2445f98b829..1f52c89edba 100644 --- a/jetty-start/src/test/resources/usecases/empty.addToStartCreateStartd.assert.txt +++ b/jetty-start/src/test/resources/usecases/empty.addToStartCreateStartd.assert.txt @@ -23,4 +23,4 @@ EXISTS|start.d/extra.ini EXISTS|start.d/optional.ini # Output Assertions [regex!] (order is irrelevant) -OUTPUT|MKDIR: \$\{jetty.base\}/maindir \ No newline at end of file +OUTPUT|MKDIR : \$\{jetty.base\}/maindir \ No newline at end of file