package derms.util; import java.io.*; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class TestLogger { private static final String LOG_FILE = "SystemTest.log"; public static void log(String message) { try (BufferedWriter writer = new BufferedWriter(new FileWriter(LOG_FILE, true))) { String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); writer.write("[" + timestamp + "] " + message); writer.newLine(); } catch (IOException e) { e.printStackTrace(); } } public static void clearLog() { try (BufferedWriter writer = new BufferedWriter(new FileWriter(LOG_FILE))) { // Clear the file by overwriting it with nothing } catch (IOException e) { e.printStackTrace(); } } }