diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java index b2376ce..e4f7fe8 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/LoggerPlugin.java @@ -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); } }); } diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/FileLoggerUtilities.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/FileLoggerUtilities.java index 8ef653b..2cf2b42 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/util/FileLoggerUtilities.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/util/FileLoggerUtilities.java @@ -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(); }