From ea7159dba63f045d52891cbcab9b9164d25a6e5c Mon Sep 17 00:00:00 2001 From: Gravita Date: Tue, 4 May 2021 19:26:00 +0700 Subject: [PATCH] [FEATURE] Print java version in `version` command --- .../launchserver/command/basic/VersionCommand.java | 11 ++++++++++- .../launchserver/command/modules/ModulesCommand.java | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/VersionCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/VersionCommand.java index e5b4434c..2c5d142a 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/VersionCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/basic/VersionCommand.java @@ -1,11 +1,17 @@ package pro.gravit.launchserver.command.basic; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.command.Command; import pro.gravit.utils.Version; +import pro.gravit.utils.helper.JVMHelper; import pro.gravit.utils.helper.LogHelper; +import java.lang.management.RuntimeMXBean; + public final class VersionCommand extends Command { + private transient final Logger logger = LogManager.getLogger(); public VersionCommand(LaunchServer server) { super(server); } @@ -22,6 +28,9 @@ public String getUsageDescription() { @Override public void invoke(String... args) { - LogHelper.subInfo("LaunchServer version: %d.%d.%d (build #%d)", Version.MAJOR, Version.MINOR, Version.PATCH, Version.BUILD); + logger.info("LaunchServer version: {}.{}.{} (build #{})", Version.MAJOR, Version.MINOR, Version.PATCH, Version.BUILD); + RuntimeMXBean mxBean = JVMHelper.RUNTIME_MXBEAN; + logger.info("Java {}({})", JVMHelper.getVersion(), mxBean.getVmVersion()); + logger.info("Java Home: {}", System.getProperty("java.home", "UNKNOWN")); } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/modules/ModulesCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/modules/ModulesCommand.java index 4b557a1d..bcc9d80e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/modules/ModulesCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/modules/ModulesCommand.java @@ -14,7 +14,7 @@ import java.util.Arrays; public class ModulesCommand extends Command { - private transient Logger logger = LogManager.getLogger(); + private transient final Logger logger = LogManager.getLogger(); public ModulesCommand(LaunchServer server) { super(server); }