Add colorization in System.err logs (#83)

Add colorization in System.err logs
Errors are reds, Warnings are yellow, Infos are green

Co-authored-by: Louis <louis.royer@univ-tlse3.fr>
This commit is contained in:
Louis Royer 2020-03-25 13:24:56 +01:00
parent 07cecf2fab
commit 15e1bd2e75
2 changed files with 7 additions and 3 deletions

View File

@ -34,17 +34,21 @@ public class Logger {
* @param text Text to log
*/
public void write(String text, LogLevel logLevel) {
String colorize = "\u001B[0";
String msg = "[" + new Timestamp(System.currentTimeMillis()) + "] " + text + "\n";
String level = null;
switch (logLevel) {
case Error:
level = "[Error]";
colorize = "\u001B[31m"; // RED
break;
case Info:
level = "[Info]";
colorize = "\u001B[32m"; // GREEN
break;
case Warning:
level = "[Warning]";
colorize = "\u001B[33m"; // YELLOW
break;
case Action:
level = "[Action]";
@ -64,7 +68,7 @@ public class Logger {
case Warning:
case Debug:
default:
System.err.println(text);
System.err.println(colorize + text + "\u001B[0m");
break;
case Action:
break;

View File

@ -6,7 +6,7 @@ package tools;
* @author JS Auge
* @version 1.0
*/
public class PortRange {
public abstract class PortRange {
protected int portMax;
protected int portMin;
@ -34,7 +34,7 @@ public class PortRange {
}
/** To String
* @return String representation
* @return String representation
*/
public String toString() {
return "default " + type + "port: " + defaultPort + "(range: " + portMin + " -> " + portMax + ")";