Merge pull request #36 from MatrixTunnel/feature/start-time

Add startup time to log messages
This commit is contained in:
Andrew Steinborn 2018-08-13 06:05:17 -04:00 committed by GitHub
commit ebdf5854dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,9 +4,15 @@ import com.velocitypowered.proxy.console.VelocityConsole;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
public class Velocity {
private static final Logger logger = LogManager.getLogger(Velocity.class);
private static long startTime;
static {
// We use BufferedImage for favicons, and on macOS this puts the Java application in the dock. How inconvenient.
// Force AWT to work with its head chopped off.
@ -14,12 +20,15 @@ public class Velocity {
}
public static void main(String... args) {
startTime = System.currentTimeMillis();
logger.info("Booting up Velocity...");
final VelocityServer server = VelocityServer.getServer();
server.start();
Runtime.getRuntime().addShutdownHook(new Thread(server::shutdown, "Shutdown thread"));
logger.info("Done ({}s)!", new SimpleDateFormat("ss.S", Locale.getDefault()).format(new Date(System.currentTimeMillis() - startTime)));
new VelocityConsole(server).start();
}
}