mirror of
https://github.com/games647/ColorConsole.git
synced 2024-11-23 10:55:14 +01:00
Minor clean up
This commit is contained in:
parent
85629d0c4a
commit
62ec40cc53
14
.gitignore
vendored
14
.gitignore
vendored
@ -3,21 +3,21 @@
|
||||
/.project
|
||||
/.settings
|
||||
|
||||
# netbeans
|
||||
/nbproject
|
||||
# NetBeans
|
||||
*/nbproject
|
||||
nb-configuration.xml
|
||||
|
||||
# maven
|
||||
/target
|
||||
*/target
|
||||
|
||||
# vim
|
||||
.*.sw[a-p]
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
# virtual machine crash logs, see https://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# various other potential build files
|
||||
/build
|
||||
*/build/
|
||||
/bin
|
||||
/dist
|
||||
/manifest.mf
|
||||
@ -26,7 +26,7 @@ hs_err_pid*
|
||||
# Mac filesystem dust
|
||||
.DS_Store
|
||||
|
||||
# intellij
|
||||
# IntelliJ
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
@ -39,4 +39,4 @@ hs_err_pid*
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
!gradle-wrapper.jar
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Use https://travis-ci.org/ for automatic tests
|
||||
# Use https://travis-ci.org/ for automatic testing
|
||||
|
||||
# speed up testing http://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/
|
||||
# speed up testing https://blog.travis-ci.com/2014-12-17-faster-builds-with-container-based-infrastructure/
|
||||
sudo: false
|
||||
|
||||
# This is a java project
|
||||
@ -8,6 +8,4 @@ language: java
|
||||
|
||||
script: mvn compile test
|
||||
|
||||
# We run on 8+
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
jdk: [oraclejdk8]
|
||||
|
17
ReadMe.md
17
ReadMe.md
@ -1,17 +0,0 @@
|
||||
# ColorConsole
|
||||
|
||||
![colorful log example](https://www.spigotmc.org/attachments/upload_2017-5-25_13-18-54-png.243110/)
|
||||
|
||||
## Description
|
||||
|
||||
This lightweight plugin to make your console more colorful. It colorize the message depending on the log level. This means that important error messages will be printed in a red color. This gives you and your administrators a better overview about what's happening on your server.
|
||||
|
||||
## Features
|
||||
|
||||
* Lightweight
|
||||
* Different colors for different log levels
|
||||
* Ignores specified log messages
|
||||
* Custom logFormat
|
||||
* Colorize plugin tags (customizable)
|
||||
* Easy to use config
|
||||
* Supports all versions above 1.8+
|
26
pom.xml
26
pom.xml
@ -8,15 +8,18 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ColorConsole</name>
|
||||
<version>2.3.1</version>
|
||||
<version>2.3.2</version>
|
||||
<inceptionYear>2016</inceptionYear>
|
||||
<url>http://dev.bukkit.org/bukkit-plugins/colorconsole/</url>
|
||||
<url>https://dev.bukkit.org/bukkit-plugins/colorconsole/</url>
|
||||
<description>
|
||||
Print colorful console messages depending on the logging level
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
@ -25,24 +28,13 @@
|
||||
<finalName>${project.name}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<showWarnings>true</showWarnings>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>org.fusesource.jansi:jansi</include>
|
||||
@ -103,7 +95,7 @@
|
||||
<!--Sponge-API-->
|
||||
<repository>
|
||||
<id>sponge-repo</id>
|
||||
<url>http://repo.spongepowered.org/maven</url>
|
||||
<url>https://repo.spongepowered.org/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
@ -112,7 +104,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12-R0.1-SNAPSHOT</version>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@ -127,7 +119,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spongepowered</groupId>
|
||||
<artifactId>spongeapi</artifactId>
|
||||
<version>7.0.0-SNAPSHOT</version>
|
||||
<version>6.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -16,7 +16,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class ColorConsoleBukkit extends JavaPlugin {
|
||||
|
||||
private static String TERMINAL_NAME = "TerminalConsole";
|
||||
private static final String TERMINAL_NAME = "TerminalConsole";
|
||||
|
||||
private Layout<? extends Serializable> oldLayout;
|
||||
|
||||
@ -82,11 +82,11 @@ public class ColorConsoleBukkit extends JavaPlugin {
|
||||
+ "WARN=" + getConfig().getString("WARN") + ", "
|
||||
+ "INFO=" + getConfig().getString("INFO") + ", "
|
||||
+ "DEBUG=" + getConfig().getString("DEBUG") + ", "
|
||||
+ "TRACE=" + getConfig().getString("TRACE") + "}");
|
||||
+ "TRACE=" + getConfig().getString("TRACE") + '}');
|
||||
}
|
||||
|
||||
String dateStyle = getConfig().getString("dateStyle");
|
||||
logFormat = logFormat.replaceFirst("(%d)\\{.{1,}\\}", "%style{$0}{" + dateStyle + "}");
|
||||
logFormat = logFormat.replaceFirst("(%d)\\{.{1,}\\}", "%style{$0}{" + dateStyle + '}');
|
||||
try {
|
||||
PatternLayout layout = CommonLogInstaller.createLayout(logFormat);
|
||||
CommonLogInstaller.setLayout(layout, terminalAppender);
|
||||
|
@ -14,6 +14,7 @@ import org.apache.logging.log4j.message.Message;
|
||||
import org.apache.logging.log4j.message.SimpleMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class ColorPluginAppender extends ColorAppender {
|
||||
|
||||
@ -35,7 +36,7 @@ public class ColorPluginAppender extends ColorAppender {
|
||||
@Override
|
||||
protected Collection<String> loadPluginNames() {
|
||||
return Stream.of(Bukkit.getPluginManager().getPlugins())
|
||||
.map(plugin -> plugin.getName())
|
||||
.map(Plugin::getName)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ public abstract class ColorAppender extends AbstractAppender {
|
||||
|
||||
for (Method method : LogEvent.class.getDeclaredMethods()) {
|
||||
String methodName = method.getName();
|
||||
if (methodName.equalsIgnoreCase("getLoggerFqcn")
|
||||
|| methodName.equalsIgnoreCase("getFQCN")) {
|
||||
if ("getLoggerFqcn".equalsIgnoreCase(methodName)
|
||||
|| "getFQCN".equalsIgnoreCase(methodName)) {
|
||||
loggerClassGetter = method;
|
||||
method.setAccessible(true);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class CommonFormatter {
|
||||
private final boolean colorizeTag;
|
||||
private final boolean truncateColor;
|
||||
private Map<String, String> pluginColors;
|
||||
private Map<String, String> levelColors;
|
||||
private final Map<String, String> levelColors;
|
||||
|
||||
public CommonFormatter(Collection<String> ignoreMessages, boolean colorizeTag, boolean truncateColor
|
||||
, Map<String, String> levelColors) {
|
||||
@ -37,7 +37,7 @@ public class CommonFormatter {
|
||||
|
||||
Builder<String, String> builder = ImmutableMap.builder();
|
||||
for (Map.Entry<String, String> entry : levelColors.entrySet()) {
|
||||
if (entry.getKey().equals("INFO")) {
|
||||
if ("INFO".equals(entry.getKey())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class CommonFormatter {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void initPluginColors(Collection<String> plugins, Map<String, String> configColors, String def) {
|
||||
public void initPluginColors(Iterable<String> plugins, Map<String, String> configColors, String def) {
|
||||
Random random = new Random();
|
||||
Color[] colors = Color.values();
|
||||
//remove black, because it's often hard to read
|
||||
@ -70,7 +70,7 @@ public class CommonFormatter {
|
||||
ImmutableMap.Builder<String, String> colorBuilder = ImmutableMap.builder();
|
||||
for (String plugin : plugins) {
|
||||
String styleCode = configColors.getOrDefault(plugin, def);
|
||||
if (styleCode.equalsIgnoreCase("random")) {
|
||||
if ("random".equalsIgnoreCase(styleCode)) {
|
||||
//ignore default
|
||||
styleCode = colors[random.nextInt(colors.length - 1)].name();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -26,47 +27,47 @@ public class ColorConsoleConfig {
|
||||
}
|
||||
|
||||
@Setting(comment = "Should the plugin tag [PLUGIN_NAME] be highlighted")
|
||||
private boolean colorPluginTag = true;
|
||||
private final boolean colorPluginTag = true;
|
||||
|
||||
@Setting(comment = "Should the log message be highlighted depending on the logging level")
|
||||
private boolean colorLoggingLevel = true;
|
||||
private final boolean colorLoggingLevel = true;
|
||||
|
||||
@Setting(comment = "How the messages should be displayed\n"
|
||||
+ "\n"
|
||||
+ '\n'
|
||||
+ "Variables:\n"
|
||||
+ "%thread - Thread name\n"
|
||||
+ "%d{HH:mm:ss} - Timestamp\n"
|
||||
+ "%msg - log message\n"
|
||||
+ "%logger - logger name\n"
|
||||
+ "%n - new line\n"
|
||||
+ "\n"
|
||||
+ "These variables try to get the orgin. This is an expensive operation and may impact performance. "
|
||||
+ '\n'
|
||||
+ "These variables try to get the origin. This is an expensive operation and may impact performance. "
|
||||
+ "Use with caution.\n"
|
||||
+ "\n"
|
||||
+ '\n'
|
||||
+ "%class{precision} - Class name\n"
|
||||
+ "%method - Method name\n"
|
||||
+ "%line - Line number\n"
|
||||
+ "\n"
|
||||
+ "For more details vist: https://logging.apache.org/log4j/2.x/manual/layouts.html#Patterns")
|
||||
private String logFormat = "[%d{HH:mm:ss} %level] [%logger{1}]: %msg%n";
|
||||
+ '\n'
|
||||
+ "For more details visit: https://logging.apache.org/log4j/2.x/manual/layouts.html#Patterns")
|
||||
private final String logFormat = "[%d{HH:mm:ss} %level] [%logger{1}]: %msg%n";
|
||||
|
||||
@Setting(comment = "Log Level Colors")
|
||||
private Map<String, String> levelColors;
|
||||
private final Map<String, String> levelColors;
|
||||
|
||||
@Setting(comment = "Plugin Colors or random")
|
||||
private String defaultPluginColor = "blue";
|
||||
private final String defaultPluginColor = "blue";
|
||||
|
||||
@Setting(comment = "Custom plugin colors")
|
||||
private Map<String, String> pluginColors;
|
||||
private final Map<String, String> pluginColors;
|
||||
|
||||
@Setting(comment = "How should the time be highlighted\n" +
|
||||
"Like below it could also be default which means it's the default font color depending on " +
|
||||
"your terminal settings.")
|
||||
private String dateStyle = "cyan";
|
||||
private final String dateStyle = "cyan";
|
||||
|
||||
@Setting(comment = "Hides the log message if it contains one or more of the following texts\n"
|
||||
+ "The texts are case-sensitive")
|
||||
private List<String> hideMessages = Lists.newArrayList();
|
||||
private final List<String> hideMessages = Lists.newArrayList();
|
||||
|
||||
@Setting(comment = "Removes color formatting if the complete message has color formatting")
|
||||
private boolean truncateColor;
|
||||
@ -100,7 +101,7 @@ public class ColorConsoleConfig {
|
||||
return pluginColors;
|
||||
}
|
||||
|
||||
public Set<String> getHideMessages() {
|
||||
public Collection<String> getHideMessages() {
|
||||
return ImmutableSet.copyOf(hideMessages);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ public class ColorConsoleSponge {
|
||||
|
||||
// private static String TERMINAL_NAME = "FmlConsole";
|
||||
// private static String TERMINAL_NAME = "Console";
|
||||
private static String TERMINAL_NAME = "MinecraftConsole";
|
||||
private static final String TERMINAL_NAME = "MinecraftConsole";
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
@ -93,11 +93,11 @@ public class ColorConsoleSponge {
|
||||
+ "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") + '}');
|
||||
}
|
||||
|
||||
String dateStyle = configMapper.getInstance().getDateStyle();
|
||||
logFormat = logFormat.replace("%d{HH:mm:ss}", "%style{" + "%d{HH:mm:ss}" + "}{" + dateStyle + "}");
|
||||
logFormat = logFormat.replace("%d{HH:mm:ss}", "%style{" + "%d{HH:mm:ss}" + "}{" + dateStyle + '}');
|
||||
|
||||
try {
|
||||
PatternLayout layout = CommonLogInstaller.createLayout(logFormat);
|
||||
|
@ -9,6 +9,7 @@ import java.util.stream.Collectors;
|
||||
import org.apache.logging.log4j.core.Appender;
|
||||
import org.apache.logging.log4j.core.LogEvent;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.plugin.PluginContainer;
|
||||
|
||||
public class ColorPluginAppender extends ColorAppender {
|
||||
|
||||
@ -26,7 +27,7 @@ public class ColorPluginAppender extends ColorAppender {
|
||||
@Override
|
||||
protected Collection<String> loadPluginNames() {
|
||||
return Sponge.getPluginManager().getPlugins().stream()
|
||||
.map(pluginContainer -> pluginContainer.getId())
|
||||
.map(PluginContainer::getId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ name: ${project.name}
|
||||
main: ${project.groupId}.${project.artifactId}.bungee.${project.name}Bungee
|
||||
|
||||
version: ${project.version}
|
||||
author: games647, http://github.com/games647/ColorConsole/graphs/contributors
|
||||
author: games647, https://github.com/games647/ColorConsole/graphs/contributors
|
||||
|
||||
description: |
|
||||
${project.description}
|
||||
${project.description}
|
||||
|
@ -17,12 +17,12 @@ colorMessage: false
|
||||
# %d{HH:mm:ss} - Timestamp
|
||||
# %msg - log message
|
||||
# %n - new line
|
||||
# These variables try to get the orgin. This is an expensive operation and may impact performance. Use with caution.
|
||||
# These variables try to get the origin. This is an expensive operation and may impact performance. Use with caution.
|
||||
# %class{precision} - Class name
|
||||
# %method - Method name
|
||||
# %line - Line number
|
||||
#
|
||||
# For more details vist: https://logging.apache.org/log4j/2.x/manual/layouts.html#Patterns
|
||||
# For more details visit: https://logging.apache.org/log4j/2.x/manual/layouts.html#Patterns
|
||||
logFormat: '[%d{HH:mm:ss} %level]: %msg%n'
|
||||
|
||||
# Log Level Colors
|
||||
|
@ -1,10 +1,10 @@
|
||||
# project informations for Bukkit in order to register our plugin with all it components
|
||||
# project data for Bukkit in order to register our plugin with all it components
|
||||
# ${-} are variables from Maven (pom.xml) which will be replaced after the build
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: ${project.groupId}.${project.artifactId}.bukkit.${project.name}Bukkit
|
||||
|
||||
# meta informations for plugin managers
|
||||
# meta data for plugin managers
|
||||
authors: [games647, 'https://github.com/games647/ColorConsole/graphs/contributors']
|
||||
description: |
|
||||
${project.description}
|
||||
|
Loading…
Reference in New Issue
Block a user