Запись лога в файл переложили на логгер
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -27,3 +27,4 @@ lib/
|
|||||||
baseq2/
|
baseq2/
|
||||||
baseq2.rar
|
baseq2.rar
|
||||||
TODO.txt
|
TODO.txt
|
||||||
|
qconsole.log
|
||||||
@@ -4,10 +4,14 @@
|
|||||||
<Console name="Console" target="SYSTEM_OUT">
|
<Console name="Console" target="SYSTEM_OUT">
|
||||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%-5level] (%t) \{%logger{36}\} %msg%n"/>
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%-5level] (%t) \{%logger{36}\} %msg%n"/>
|
||||||
</Console>
|
</Console>
|
||||||
|
<File name="File" fileName="qconsole.log" append="true">
|
||||||
|
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%-5level] (%t) \{%logger{36}\} %msg%n"/>
|
||||||
|
</File>
|
||||||
</Appenders>
|
</Appenders>
|
||||||
<Loggers>
|
<Loggers>
|
||||||
<Root level="all">
|
<Root level="all">
|
||||||
<AppenderRef ref="Console"/>
|
<AppenderRef ref="Console"/>
|
||||||
|
<AppenderRef ref="File"/>
|
||||||
</Root>
|
</Root>
|
||||||
</Loggers>
|
</Loggers>
|
||||||
</Configuration>
|
</Configuration>
|
||||||
@@ -27,10 +27,10 @@ import lwjake2.server.SV_MAIN;
|
|||||||
import lwjake2.sys.Sys;
|
import lwjake2.sys.Sys;
|
||||||
import lwjake2.util.PrintfFormat;
|
import lwjake2.util.PrintfFormat;
|
||||||
import lwjake2.util.Vargs;
|
import lwjake2.util.Vargs;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Com
|
* Com
|
||||||
@@ -38,7 +38,7 @@ import java.io.RandomAccessFile;
|
|||||||
*/
|
*/
|
||||||
public final class Com
|
public final class Com
|
||||||
{
|
{
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(Com.class);
|
||||||
static String debugContext = "";
|
static String debugContext = "";
|
||||||
static String _debugContext = "";
|
static String _debugContext = "";
|
||||||
|
|
||||||
@@ -356,50 +356,12 @@ public final class Com
|
|||||||
Console.Print(msg);
|
Console.Print(msg);
|
||||||
|
|
||||||
// also echo to debugging console
|
// also echo to debugging console
|
||||||
Sys.ConsoleOutput(msg);
|
while (msg.startsWith("\n")) { msg = msg.substring(1); }
|
||||||
|
while (msg.endsWith("\n")) { msg = msg.substring(0, msg.lastIndexOf("\n")); }
|
||||||
// logfile
|
while (msg.endsWith("\r")) { msg = msg.substring(0, msg.lastIndexOf("\r")); }
|
||||||
if (Globals.logfile_active != null && Globals.logfile_active.value != 0)
|
msg = msg.trim();
|
||||||
{
|
if (!msg.isEmpty()) {
|
||||||
String name;
|
logger.info(msg);
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,18 +229,4 @@ public final class Sys extends Defines {
|
|||||||
return null;
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user