From 2d1702ce5f1e1be52a98a715aa1a48de3810399b Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Fri, 12 May 2017 11:42:08 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=BF=D0=B8=D1=81=D1=8C=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B0=20=D0=B2=20=D1=84=D0=B0=D0=B9=D0=BB=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BB=D0=BE=D0=B6=D0=B8=D0=BB=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B3=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- resources/log4j2.xml | 4 +++ src/lwjake2/qcommon/Com.java | 56 ++++++------------------------------ src/lwjake2/sys/Sys.java | 14 --------- 4 files changed, 15 insertions(+), 62 deletions(-) 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