From a7b0c6f4fbaea32b32a42ee48671635bc0c26f5e Mon Sep 17 00:00:00 2001 From: Louis Date: Wed, 25 Mar 2020 13:23:25 +0100 Subject: [PATCH] Add colorization in System.err logs Errors are reds, Warnings are yellow, Infos are green --- src/tools/Logger.java | 6 +++++- src/tools/PortRange.java | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/tools/Logger.java b/src/tools/Logger.java index 1fdb4ad..ce0f82e 100644 --- a/src/tools/Logger.java +++ b/src/tools/Logger.java @@ -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; diff --git a/src/tools/PortRange.java b/src/tools/PortRange.java index 290cc94..ef184ab 100644 --- a/src/tools/PortRange.java +++ b/src/tools/PortRange.java @@ -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 + ")"; -- 2.30.2