mirror of
https://github.com/games647/ColorConsole.git
synced 2024-11-23 19:05:19 +01:00
Added config
This commit is contained in:
parent
b3a825a6c9
commit
e1e1c60e51
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ColorConsole</name>
|
||||
<version>1.1</version>
|
||||
<version>1.2</version>
|
||||
<inceptionYear>2016</inceptionYear>
|
||||
<url>http://dev.bukkit.org/bukkit-plugins/colorconsole/</url>
|
||||
<description>
|
||||
|
@ -21,12 +21,16 @@ public class ColorConsole extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
saveDefaultConfig();
|
||||
|
||||
//try to run it as early as possible
|
||||
installLogFormat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
saveDefaultConfig();
|
||||
|
||||
installLogFormat();
|
||||
}
|
||||
|
||||
@ -55,19 +59,25 @@ public class ColorConsole extends JavaPlugin {
|
||||
Appender terminalAppender = getTerminalAppender();
|
||||
|
||||
oldLayout = terminalAppender.getLayout();
|
||||
String logFormat = getConfig().getString("logFormat");
|
||||
if (getConfig().getBoolean("colorLoggingLevel")) {
|
||||
logFormat = "%highlight{" + logFormat + "}{"
|
||||
+ "FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=gray, DEBUG=green bold, TRACE=blue}";
|
||||
}
|
||||
|
||||
PatternLayout layout = PatternLayout
|
||||
.createLayout("%highlight{[%d{HH:mm:ss} %-5level]: %msg%n}{FATAL=red blink, ERROR=red, "
|
||||
+ "WARN=yellow bold, INFO=gray, DEBUG=green bold, TRACE=blue}", new DefaultConfiguration()
|
||||
, null, Charset.defaultCharset().name(), "true");
|
||||
.createLayout(logFormat, new DefaultConfiguration(), null, Charset.defaultCharset().name(), "true");
|
||||
setLayout(layout);
|
||||
|
||||
Logger rootLogger = ((Logger) LogManager.getRootLogger());
|
||||
if (getConfig().getBoolean("colorPluginTag")) {
|
||||
Logger rootLogger = ((Logger) LogManager.getRootLogger());
|
||||
|
||||
ColorPluginAppender pluginAppender = new ColorPluginAppender(terminalAppender);
|
||||
pluginAppender.start();
|
||||
ColorPluginAppender pluginAppender = new ColorPluginAppender(terminalAppender);
|
||||
pluginAppender.start();
|
||||
|
||||
rootLogger.removeAppender(terminalAppender);
|
||||
rootLogger.addAppender(pluginAppender);
|
||||
rootLogger.removeAppender(terminalAppender);
|
||||
rootLogger.addAppender(pluginAppender);
|
||||
}
|
||||
}
|
||||
|
||||
private void setLayout(Layout<? extends Serializable> layout) {
|
||||
|
22
src/main/resources/config.yml
Normal file
22
src/main/resources/config.yml
Normal file
@ -0,0 +1,22 @@
|
||||
# ConsoleColor config
|
||||
|
||||
# Should the plugin tag [PLUGIN_NAME] be highlighted
|
||||
colorPluginTag: true
|
||||
|
||||
# Should the log message be highlighted depending on the logging level
|
||||
colorLoggingLevel: true
|
||||
|
||||
# How the messages should be displayed
|
||||
#
|
||||
# Variables:
|
||||
# %thread - Thread name
|
||||
# %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.
|
||||
# %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
|
||||
logFormat: '[%d{HH:mm:ss} %-5level]: %msg%n'
|
Loading…
Reference in New Issue
Block a user