Improve logging modules and listing #984

Use ERROR instead of WARN for fatal start problems
improved log formatting
This commit is contained in:
Greg Wilkins 2016-10-19 11:21:46 +11:00
parent 7bbfd618e3
commit a0a1c83964
5 changed files with 19 additions and 14 deletions

View File

@ -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)

View File

@ -363,7 +363,7 @@ public class Modules implements Iterable<Module>
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<Module>
{
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<Module>
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);
}
});
});

View File

@ -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)

View File

@ -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]

View File

@ -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
OUTPUT|MKDIR : \$\{jetty.base\}/maindir