diff --git a/.gitignore b/.gitignore index 2893ef0..8df98e6 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ target/ lib/ baseq2/ baseq2.rar -TODO.txt \ No newline at end of file +TODO.txt +qconsole.log \ No newline at end of file diff --git a/resources/log4j2.xml b/resources/log4j2.xml index 2235f2c..f86c176 100644 --- a/resources/log4j2.xml +++ b/resources/log4j2.xml @@ -4,10 +4,14 @@ + + + + \ No newline at end of file diff --git a/src/lwjake2/qcommon/Com.java b/src/lwjake2/qcommon/Com.java index 6bdc76b..ee00dda 100644 --- a/src/lwjake2/qcommon/Com.java +++ b/src/lwjake2/qcommon/Com.java @@ -27,10 +27,10 @@ import lwjake2.server.SV_MAIN; import lwjake2.sys.Sys; import lwjake2.util.PrintfFormat; import lwjake2.util.Vargs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.RandomAccessFile; /** * Com @@ -38,7 +38,7 @@ import java.io.RandomAccessFile; */ public final class Com { - + private static final Logger logger = LoggerFactory.getLogger(Com.class); static String debugContext = ""; static String _debugContext = ""; @@ -356,50 +356,12 @@ public final class Com Console.Print(msg); // also echo to debugging console - Sys.ConsoleOutput(msg); - - // logfile - if (Globals.logfile_active != null && Globals.logfile_active.value != 0) - { - String name; - - if (Globals.logfile == null) - { - name= FS.Gamedir() + "/qconsole.log"; - if (Globals.logfile_active.value > 2) - try - { - Globals.logfile = new RandomAccessFile(name, "rw"); - Globals.logfile.seek(Globals.logfile.length()); - } - catch (Exception e) - { - // TODO: do quake2 error handling! - e.printStackTrace(); - } - else - try - { - Globals.logfile= new RandomAccessFile(name, "rw"); - } - catch (FileNotFoundException e1) - { - // TODO: do quake2 error handling! - e1.printStackTrace(); - } - } - if (Globals.logfile != null) - try - { - Globals.logfile.writeChars(msg); - } - catch (IOException e) - { - // TODO: do quake2 error handling! - e.printStackTrace(); - } - if (Globals.logfile_active.value > 1); // do nothing - // fflush (logfile); // force it to save every time + while (msg.startsWith("\n")) { msg = msg.substring(1); } + while (msg.endsWith("\n")) { msg = msg.substring(0, msg.lastIndexOf("\n")); } + while (msg.endsWith("\r")) { msg = msg.substring(0, msg.lastIndexOf("\r")); } + msg = msg.trim(); + if (!msg.isEmpty()) { + logger.info(msg); } } diff --git a/src/lwjake2/sys/Sys.java b/src/lwjake2/sys/Sys.java index 42acc99..d190064 100644 --- a/src/lwjake2/sys/Sys.java +++ b/src/lwjake2/sys/Sys.java @@ -229,18 +229,4 @@ public final class Sys extends Defines { return null; } - public static void ConsoleOutput(String msg) { - if (Globals.nostdout != null && Globals.nostdout.value != 0) - return; - - while (msg.startsWith("\n")) { - msg = msg.substring(1); - } - while (msg.endsWith("\n")) { - msg = msg.substring(0, msg.lastIndexOf("\n")); - } - - logger.info(msg); - } - } \ No newline at end of file