diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 8ca190ad..6810a7e8 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -384,7 +384,6 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE modulesManager.autoload(dir.resolve("modules")); modulesManager.preInitModules(); initGson(); - LogHelper.setStacktraceEnabled(true); // Read LaunchServer config generateConfigIfNotExists(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java index 19adc8b6..89c6a12a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java @@ -11,22 +11,29 @@ public DebugCommand(LaunchServer server) { @Override public String getArgsDescription() { - return "[true/false]"; + return "[true/false] (true/false)"; } @Override public String getUsageDescription() { - return "Enable or disable debug logging at runtime"; + return "Enable or disable debug and stacktrace logging at runtime"; } @Override public void invoke(String... args) { - boolean newValue; + boolean newValue, newTraceValue; if (args.length >= 1) { newValue = Boolean.parseBoolean(args[0]); + if(args.length >= 2) newTraceValue = Boolean.parseBoolean(args[1]); + else newTraceValue = newValue; LogHelper.setDebugEnabled(newValue); + LogHelper.setStacktraceEnabled(newTraceValue); } else + { newValue = LogHelper.isDebugEnabled(); + newTraceValue = LogHelper.isStacktraceEnabled(); + } LogHelper.subInfo("Debug enabled: " + newValue); + LogHelper.subInfo("Stacktrace enabled: " + newTraceValue); } } diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index 932dc823..c8b4c21f 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -30,6 +30,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep args.add(javaBin.toString()); String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled()))); + args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled()))); Collections.addAll(args, "-javaagent:".concat(pathLauncher)); Collections.addAll(args, "-cp"); Collections.addAll(args, pathLauncher); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index da2f81ad..c795199f 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -356,6 +356,7 @@ public static Process launch( args.add("-Xmx" + params.ram + 'M'); } args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled()))); + args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled()))); if (LauncherConfig.ADDRESS_OVERRIDE != null) args.add(JVMHelper.jvmProperty(LauncherConfig.ADDRESS_OVERRIDE_PROPERTY, LauncherConfig.ADDRESS_OVERRIDE)); if (JVMHelper.OS_TYPE == OS.MUSTDIE) { diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index e42b62a7..8fcdeada 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -87,6 +87,7 @@ public static void main(String[] args) throws Throwable { modulesManager.preInitModules(); LogHelper.debug("Read ServerWrapperConfig.json"); gsonBuiler = new GsonBuilder(); + gsonBuiler.setPrettyPrinting(); gson = gsonBuiler.create(); generateConfigIfNotExists(); try(Reader reader = IOHelper.newReader(configFile)) @@ -99,7 +100,7 @@ public static void main(String[] args) throws Throwable { else CommonHelper.newThread("Server Auth Thread", true, () -> ServerWrapper.loopAuth(wrapper, config.reconnectCount, config.reconnectSleep)); modulesManager.initModules(); - String classname = config.mainclass.isEmpty() ? args[0] : config.mainclass; + String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass; if (classname.length() == 0) { LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.cfg or first commandline argument"); } @@ -152,6 +153,7 @@ private static void generateConfigIfNotExists() throws IOException { newConfig.port = 7240; newConfig.login = "login"; newConfig.password = "password"; + newConfig.mainclass = ""; //try(Reader reader = IOHelper.newReader(IOHelper.getResourceURL("ru/gravit/launcher/server/ServerWrapper.cfg"))) //{ // newConfig = gson.fromJson(reader,Config.class);