From e990efc1b130d140161eefc62e809d23956c4a73 Mon Sep 17 00:00:00 2001 From: games647 Date: Fri, 19 May 2017 10:42:32 +0200 Subject: [PATCH] Colorize only the logging level not the complete message --- pom.xml | 17 ++++++++--------- .../colorconsole/bukkit/ColorConsoleBukkit.java | 4 ++-- .../colorconsole/bungee/ColorLogFormatter.java | 2 ++ .../colorconsole/sponge/ColorConsoleSponge.java | 6 +++--- 4 files changed, 15 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 083869b..bde9e65 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ jar ColorConsole - 1.8 + 1.9 2016 http://dev.bukkit.org/bukkit-plugins/colorconsole/ @@ -41,7 +41,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.6.0 + 3.6.1 1.8 1.8 @@ -102,7 +102,7 @@ org.spigotmc spigot-api - 1.9-R0.1-SNAPSHOT + 1.12-pre2-SNAPSHOT provided @@ -117,16 +117,15 @@ org.spongepowered spongeapi - 5.0.0 - jar + 6.1.0-20170502.022019-1 provided - org.fusesource.jansi - jansi - 1.11 - provided + jline + jline + 2.12.1 + compile diff --git a/src/main/java/com/github/games647/colorconsole/bukkit/ColorConsoleBukkit.java b/src/main/java/com/github/games647/colorconsole/bukkit/ColorConsoleBukkit.java index 24b76eb..ec489b3 100644 --- a/src/main/java/com/github/games647/colorconsole/bukkit/ColorConsoleBukkit.java +++ b/src/main/java/com/github/games647/colorconsole/bukkit/ColorConsoleBukkit.java @@ -62,13 +62,13 @@ public class ColorConsoleBukkit extends JavaPlugin { oldLayout = terminalAppender.getLayout(); String logFormat = getConfig().getString("logFormat"); if (getConfig().getBoolean("colorLoggingLevel")) { - logFormat = "%highlight{" + logFormat + "}{" + logFormat = "[%highlight{%d{HH:mm:ss} %level}{" + logFormat + "}{" + "FATAL=" + getConfig().getString("FATAL") + ", " + "ERROR=" + getConfig().getString("ERROR") + ", " + "WARN=" + getConfig().getString("WARN") + ", " + "INFO=" + getConfig().getString("INFO") + ", " + "DEBUG=" + getConfig().getString("DEBUG") + ", " - + "TRACE=" + getConfig().getString("TRACE") + "}"; + + "TRACE=" + getConfig().getString("TRACE") + "}] %msg%n"; } PatternLayout layout = PatternLayout diff --git a/src/main/java/com/github/games647/colorconsole/bungee/ColorLogFormatter.java b/src/main/java/com/github/games647/colorconsole/bungee/ColorLogFormatter.java index 6068359..b2501ad 100644 --- a/src/main/java/com/github/games647/colorconsole/bungee/ColorLogFormatter.java +++ b/src/main/java/com/github/games647/colorconsole/bungee/ColorLogFormatter.java @@ -66,6 +66,8 @@ public class ColorLogFormatter extends Formatter { formatted.append(record.getLevel().getName()); formatted.append("] "); + formatted.append(Ansi.ansi().reset().toString()); + if (plugin.getConfiguration().getBoolean("colorPluginTag")) { message = colorizePluginTag(message, levelColor); } diff --git a/src/main/java/com/github/games647/colorconsole/sponge/ColorConsoleSponge.java b/src/main/java/com/github/games647/colorconsole/sponge/ColorConsoleSponge.java index 22686e6..9664f67 100644 --- a/src/main/java/com/github/games647/colorconsole/sponge/ColorConsoleSponge.java +++ b/src/main/java/com/github/games647/colorconsole/sponge/ColorConsoleSponge.java @@ -27,7 +27,7 @@ import java.lang.reflect.Field; import java.nio.charset.Charset; import java.nio.file.Path; -@Plugin(id = "colorconsole", name = "ColorConsole", version = "1.6" +@Plugin(id = "colorconsole", name = "ColorConsole", version = "1.9" , url = "https://github.com/games647/ColorConsole/" , description = "Print colorful console messages depending on the logging level") public class ColorConsoleSponge { @@ -89,13 +89,13 @@ public class ColorConsoleSponge { String logFormat = configMapper.getInstance().getLogFormat(); if (configMapper.getInstance().isColorLoggingLevel()) { - logFormat = "%highlight{" + logFormat + "}{" + logFormat = "[%highlight{%d{HH:mm:ss} %level}{" + logFormat + "}{" + "FATAL=" + configMapper.getInstance().getLevelColors().get("FATAL") + ", " + "ERROR=" + configMapper.getInstance().getLevelColors().get("ERROR") + ", " + "WARN=" + configMapper.getInstance().getLevelColors().get("WARN") + ", " + "INFO=" + configMapper.getInstance().getLevelColors().get("INFO") + ", " + "DEBUG=" + configMapper.getInstance().getLevelColors().get("DEBUG") + ", " - + "TRACE=" + configMapper.getInstance().getLevelColors().get("TRACE") + "}"; + + "TRACE=" + configMapper.getInstance().getLevelColors().get("TRACE") + "}] %msg%n"; } PatternLayout layout = PatternLayout