turn off startlog redirect when starting

This commit is contained in:
Greg Wilkins 2014-05-26 00:46:32 +02:00
parent 5edf15241b
commit 0d70ae87b2
2 changed files with 28 additions and 11 deletions

View File

@ -227,6 +227,7 @@ public class Main
private void dumpClasspathWithVersions(Classpath classpath)
{
StartLog.endStartLog();
System.out.println();
System.out.println("Jetty Server Classpath:");
System.out.println("-----------------------");
@ -301,11 +302,14 @@ public class Main
Method main = invoked_class.getDeclaredMethod("main",method_param_types);
Object[] method_params = new Object[]
{ argArray };
StartLog.endStartLog();
main.invoke(null,method_params);
}
public void listConfig(StartArgs args)
{
StartLog.endStartLog();
// Dump Jetty Home / Base
args.dumpEnvironment(baseHome);
@ -327,6 +331,7 @@ public class Main
private void listModules(StartArgs args)
{
StartLog.endStartLog();
System.out.println();
System.out.println("Jetty All Available Modules:");
System.out.println("----------------------------");
@ -714,6 +719,7 @@ public class Main
CommandLineBuilder cmd = args.getMainArgs(baseHome,true);
cmd.debug();
ProcessBuilder pbuilder = new ProcessBuilder(cmd.getArgs());
StartLog.endStartLog();
final Process process = pbuilder.start();
Runtime.getRuntime().addShutdownHook(new Thread()
{
@ -825,6 +831,7 @@ public class Main
public void usage(boolean exit)
{
StartLog.endStartLog();
String usageResource = "org/eclipse/jetty/start/usage.txt";
boolean usagePresented = false;
try (InputStream usageStream = getClass().getClassLoader().getResourceAsStream(usageResource))

View File

@ -37,13 +37,17 @@ import org.eclipse.jetty.start.config.CommandLineConfigSource;
*/
public class StartLog
{
private final static PrintStream stdout = System.out;
private final static PrintStream stderr = System.err;
private static volatile PrintStream out = System.out;
private static volatile PrintStream err = System.err;
private final static StartLog INSTANCE = new StartLog();
public static void debug(String format, Object... args)
{
if (INSTANCE.debug)
{
INSTANCE.out.printf(format + "%n",args);
out.printf(format + "%n",args);
}
}
@ -51,7 +55,7 @@ public class StartLog
{
if (INSTANCE.debug)
{
t.printStackTrace(INSTANCE.out);
t.printStackTrace(out);
}
}
@ -62,17 +66,17 @@ public class StartLog
public static void info(String format, Object... args)
{
INSTANCE.err.printf("INFO: " + format + "%n",args);
err.printf("INFO: " + format + "%n",args);
}
public static void warn(String format, Object... args)
{
INSTANCE.err.printf("WARNING: " + format + "%n",args);
err.printf("WARNING: " + format + "%n",args);
}
public static void warn(Throwable t)
{
t.printStackTrace(INSTANCE.err);
t.printStackTrace(err);
}
public static boolean isDebugEnabled()
@ -81,8 +85,6 @@ public class StartLog
}
private boolean debug = false;
private PrintStream out = System.out;
private PrintStream err = System.err;
public void initialize(BaseHome baseHome, CommandLineConfigSource cmdLineSource) throws IOException
{
@ -140,10 +142,12 @@ public class StartLog
}
err.println("StartLog to " + logfile);
OutputStream out = Files.newOutputStream(startLog,StandardOpenOption.CREATE,StandardOpenOption.APPEND);
PrintStream logger = new PrintStream(out);
err=logger;
OutputStream fileout = Files.newOutputStream(startLog,StandardOpenOption.CREATE,StandardOpenOption.APPEND);
PrintStream logger = new PrintStream(fileout);
out=logger;
err=logger;
System.setErr(logger);
System.setOut(logger);
err.println("StartLog Establishing " + logfile + " on " + new Date());
}
catch (IOException e)
@ -160,6 +164,12 @@ public class StartLog
public static void endStartLog()
{
if (stderr!=err && getInstance().debug)
{
err.println("StartLog ended");
stderr.println("StartLog ended");
}
System.setErr(stderr);
System.setOut(stdout);
}
}