chatprogramm was sonst
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.0 KiB

1 year ago
  1. package server.log;
  2. import java.io.PrintStream;
  3. public class EventLogger {
  4. private static final String ANSI_RESET = "\u001B[0m";
  5. private static final String ANSI_RED = "\u001B[31m";
  6. private static final String ANSI_GREEN = "\u001B[32m";
  7. private static final String ANSI_BLUE = "\u001B[34m";
  8. private static final String ANSI_WHITE = "\u001B[37m";
  9. private final PrintStream stream;
  10. public EventLogger(PrintStream stream) {
  11. this.stream = stream;
  12. }
  13. public void println(String msg) {
  14. stream.println(msg);
  15. }
  16. public void error(String msg) {
  17. stream.println(ANSI_WHITE + "[" + ANSI_RED + "-" + ANSI_WHITE + "] " + msg + ANSI_RESET);
  18. }
  19. public void info(String msg) {
  20. stream.println(ANSI_WHITE + "[" + ANSI_BLUE + "*" + ANSI_WHITE + "] " + msg + ANSI_RESET);
  21. }
  22. public void success(String msg) {
  23. stream.println(ANSI_WHITE + "[" + ANSI_GREEN + "+" + ANSI_WHITE + "] " + msg + ANSI_RESET);
  24. }
  25. public void close() {
  26. stream.close();
  27. }
  28. }