From e1d8508cf1d1e229b3684519e906ae6f10810653 Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Wed, 29 Mar 2023 07:56:21 +0700 Subject: [PATCH] actually fix stuff i guess --- .../chipmunk/chayapak/chomens_bot/Logger.java | 23 +++++++++++-------- .../chomens_bot/plugins/LoggerPlugin.java | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/Logger.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/Logger.java index e31ab46..f7e6c86 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/Logger.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/Logger.java @@ -20,7 +20,6 @@ public class Logger { public static LocalDate currentLogDate; public static final DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("'['dd/MM/yyyy HH:mm:ss']' "); - public static final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("'dd/MM/yyyy'"); public static String prevEntry = ""; public static int duplicateCounter = 1; @@ -30,14 +29,18 @@ public class Logger { public static long freezeTime = 0; static { - init(); - executor.scheduleAtFixedRate(() -> { - try { - tick(); - } catch (Exception e) { - e.printStackTrace(); - } - }, 0, 50, TimeUnit.MILLISECONDS); + try { + init(); + executor.scheduleAtFixedRate(() -> { + try { + tick(); + } catch (Exception e) { + e.printStackTrace(); + } + }, 0, 50, TimeUnit.MILLISECONDS); + } catch (Exception e) { + e.printStackTrace(); + } } public static void init() { @@ -72,7 +75,7 @@ public class Logger { } public static synchronized void makeNewLogFile() throws IOException { - currentLogDate = LocalDate.parse(LocalDate.now().format(dateFormatter)); + currentLogDate = LocalDate.now(); logWriter = new OutputStreamWriter(new FileOutputStream(logFile, false), StandardCharsets.UTF_8); logWriter.write(currentLogDate.toString() + '\n'); logWriter.flush(); 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 255e6a6..e91f431 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 @@ -22,6 +22,7 @@ public class LoggerPlugin extends ChatPlugin.ChatListener { @Override public void disconnected (DisconnectedEvent event) { + event.getCause().printStackTrace(); log("Disconnected from " + bot.host() + ":" + bot.port() + ", reason: " + event.getReason()); } });