Added log file

This commit is contained in:
Anuken
2020-01-11 20:09:20 -05:00
parent d6dec002c1
commit dbc45985ce
5 changed files with 41 additions and 15 deletions

View File

@@ -66,17 +66,17 @@ public class ServerControl implements ApplicationListener{
"globalrules", "{reactorExplosions: false}"
);
Log.setLogger((level, text, args1) -> {
String result = "[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level.ordinal()] + " " + text + "&fr", args1);
Log.setLogger((level, text) -> {
String result = "[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level.ordinal()] + " " + text + "&fr");
System.out.println(result);
if(Config.logging.bool()){
logToFile("[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level.ordinal()] + " " + text + "&fr", false, args1));
logToFile("[" + dateTime.format(LocalDateTime.now()) + "] " + formatColors(tags[level.ordinal()] + " " + text + "&fr", false));
}
if(socketOutput != null){
try{
socketOutput.println(format(text + "&fr", false, args1));
socketOutput.println(formatColors(text + "&fr", false));
}catch(Throwable e){
err("Error occurred logging to socket: {0}", e.getClass().getSimpleName());
}

View File

@@ -29,8 +29,8 @@ public class ServerLauncher implements ApplicationListener{
Vars.platform = new Platform(){};
Vars.net = new Net(platform.getNet());
Log.setLogger((level, text, args1) -> {
String result = "[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level.ordinal()] + " " + text + "&fr", args1);
Log.setLogger((level, text) -> {
String result = "[" + dateTime.format(LocalDateTime.now()) + "] " + format(tags[level.ordinal()] + " " + text + "&fr");
System.out.println(result);
});
new HeadlessApplication(new ServerLauncher(), null, throwable -> CrashSender.send(throwable, f -> {}));