This commit is contained in:
Chayapak 2023-07-30 08:21:59 +07:00
parent 4fe66333d1
commit fec4f20420
2 changed files with 13 additions and 3 deletions

View file

@ -46,8 +46,18 @@ public class LoggerPlugin extends ChatPlugin.Listener {
@Override
public void disconnected (DisconnectedEvent event) {
final String reason = ComponentUtilities.stringifyAnsi(event.getReason());
log("Disconnected from " + bot.host + ":" + bot.port + ", reason: " + reason);
final Component reason = event.getReason();
final String message = "Disconnected from " + bot.host + ":" + bot.port + ", reason: ";
final String string = ComponentUtilities.stringify(reason);
if (logToConsole) {
final String ansi = ComponentUtilities.stringifyAnsi(reason);
log(message + ansi, false, true);
}
log(message + string, true, false);
}
});
}

View file

@ -83,7 +83,7 @@ public class FileLoggerUtilities {
if (!Files.exists(logPath)) Files.createFile(logPath);
logWriter = Files.newBufferedWriter(logPath, StandardOpenOption.WRITE);
logWriter = Files.newBufferedWriter(logPath, StandardOpenOption.TRUNCATE_EXISTING);
logWriter.write(currentLogDate.toString() + '\n');
logWriter.flush();
}