23 package com.realtime.crossfire.jxclient.window;
28 import java.io.BufferedWriter;
29 import java.io.IOException;
30 import java.nio.file.Files;
31 import java.nio.file.Path;
32 import java.nio.file.StandardOpenOption;
33 import java.time.LocalDateTime;
34 import java.time.format.DateTimeFormatter;
35 import java.util.Locale;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
49 private static final DateTimeFormatter
FORMATTER = DateTimeFormatter.ofPattern(
"yyyy-MM-dd HH:mm:ss ", Locale.ENGLISH);
67 @SuppressWarnings(
"FieldCanBeLocal")
71 public void commandDrawextinfoReceived(
final int color,
final int type,
final int subtype, @NotNull
final String message) {
76 public void setDebugMode(
final boolean printMessageTypes) {
91 crossfireServerConnection.addCrossfireQueryListener((prompt, queryType) ->
log(prompt));
93 crossfireServerConnection.addCrossfireDrawinfoListener((text, type) ->
log(text));
108 private void log(@NotNull
final String message) {
113 final LocalDateTime now = LocalDateTime.now();
116 try (BufferedWriter osw = Files.newBufferedWriter(file, StandardOpenOption.CREATE, StandardOpenOption.APPEND, StandardOpenOption.WRITE)) {
117 osw.write(
FORMATTER.format(now)+message+
"\n");
119 }
catch (
final IOException ex) {
120 System.err.println(ex.getMessage());