Added logging classes to client package

This commit is contained in:
2021-02-14 16:04:03 +01:00
parent 51db69bee8
commit 6b3306a416
2 changed files with 46 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
package client.logging;
import java.sql.Timestamp;
public class ClientLogger {
private static final String ANSI_RESET = "\u001B[0m";
private static final String ANSI_BLACK = "\u001B[30m";
private static final String ANSI_RED = "\u001B[31m";
private static final String ANSI_GREEN = "\u001B[32m";
private static final String ANSI_YELLOW = "\u001B[33m";
private static final String ANSI_BLUE = "\u001B[34m";
private static final String ANSI_PURPLE = "\u001B[35m";
private static final String ANSI_CYAN = "\u001B[36m";
private static final String ANSI_WHITE = "\u001B[37m";
public void printLog(String message, String name, LogType logType, boolean success){
switch (logType){
case Log:
System.out.printf(ANSI_CYAN + "%s %s%n"+ANSI_RESET, new Timestamp(System.currentTimeMillis()), message);
break;
case Error:
System.out.printf(ANSI_RED + "%s %s%n"+ ANSI_RESET, new Timestamp(System.currentTimeMillis()), message);
break;
case Message:
System.out.printf(ANSI_WHITE + " %s %s %s%n" +ANSI_RESET, new Timestamp(System.currentTimeMillis()), name, message);
break;
default:
System.err.println("NO VALID LOGTYPE GIVEN");;
}
}
public void printLog(String message, LogType logType, boolean success){
this.printLog(message, "", logType, success);
}
}

View File

@@ -0,0 +1,7 @@
package client.logging;
public enum LogType {
Log,
Message,
Error
}