Add colorization in System.err logs
Errors are reds, Warnings are yellow, Infos are green
This commit is contained in:
parent
07cecf2fab
commit
a7b0c6f4fb
@ -34,17 +34,21 @@ public class Logger {
|
|||||||
* @param text Text to log
|
* @param text Text to log
|
||||||
*/
|
*/
|
||||||
public void write(String text, LogLevel logLevel) {
|
public void write(String text, LogLevel logLevel) {
|
||||||
|
String colorize = "\u001B[0";
|
||||||
String msg = "[" + new Timestamp(System.currentTimeMillis()) + "] " + text + "\n";
|
String msg = "[" + new Timestamp(System.currentTimeMillis()) + "] " + text + "\n";
|
||||||
String level = null;
|
String level = null;
|
||||||
switch (logLevel) {
|
switch (logLevel) {
|
||||||
case Error:
|
case Error:
|
||||||
level = "[Error]";
|
level = "[Error]";
|
||||||
|
colorize = "\u001B[31m"; // RED
|
||||||
break;
|
break;
|
||||||
case Info:
|
case Info:
|
||||||
level = "[Info]";
|
level = "[Info]";
|
||||||
|
colorize = "\u001B[32m"; // GREEN
|
||||||
break;
|
break;
|
||||||
case Warning:
|
case Warning:
|
||||||
level = "[Warning]";
|
level = "[Warning]";
|
||||||
|
colorize = "\u001B[33m"; // YELLOW
|
||||||
break;
|
break;
|
||||||
case Action:
|
case Action:
|
||||||
level = "[Action]";
|
level = "[Action]";
|
||||||
@ -64,7 +68,7 @@ public class Logger {
|
|||||||
case Warning:
|
case Warning:
|
||||||
case Debug:
|
case Debug:
|
||||||
default:
|
default:
|
||||||
System.err.println(text);
|
System.err.println(colorize + text + "\u001B[0m");
|
||||||
break;
|
break;
|
||||||
case Action:
|
case Action:
|
||||||
break;
|
break;
|
||||||
|
@ -6,7 +6,7 @@ package tools;
|
|||||||
* @author JS Auge
|
* @author JS Auge
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class PortRange {
|
public abstract class PortRange {
|
||||||
|
|
||||||
protected int portMax;
|
protected int portMax;
|
||||||
protected int portMin;
|
protected int portMin;
|
||||||
@ -34,7 +34,7 @@ public class PortRange {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** To String
|
/** To String
|
||||||
* @return String representation
|
* @return String representation
|
||||||
*/
|
*/
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "default " + type + "port: " + defaultPort + "(range: " + portMin + " -> " + portMax + ")";
|
return "default " + type + "port: " + defaultPort + "(range: " + portMin + " -> " + portMax + ")";
|
||||||
|
Loading…
Reference in New Issue
Block a user