Fix console font coloring

This commit is contained in:
huangyuhui 2017-06-11 12:24:50 +08:00
parent faa806fc9f
commit 5a6c64377a
2 changed files with 18 additions and 14 deletions

View File

@ -47,11 +47,13 @@ public enum Level {
return this.level <= level.level; return this.level <= level.level;
} }
public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\] \\[(?<category>[^\\]]+)\\]"); public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]");
public static final Pattern MINECRAFT_LOGGER_CATEGORY = Pattern.compile("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\] \\[(?<category>[^\\]]+)\\]");
public static final String JAVA_SYMBOL = "([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$][a-zA-Z\\d_$]*"; public static final String JAVA_SYMBOL = "([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$][a-zA-Z\\d_$]*";
public static Level guessLevel(String line, Level preLevel) { public static Level guessLevel(String line, Level preLevel) {
if (line.startsWith("MC:")) line = line.substring("MC:".length()); if (line.startsWith("MC:"))
line = line.substring("MC:".length());
Level level = preLevel; Level level = preLevel;
Matcher m = MINECRAFT_LOGGER.matcher(line); Matcher m = MINECRAFT_LOGGER.matcher(line);
if (m.find()) { if (m.find()) {
@ -80,9 +82,11 @@ public enum Level {
default: default:
break; break;
} }
String level2Str = m.group("category"); Matcher m2 = MINECRAFT_LOGGER_CATEGORY.matcher(line);
if (m2.find()) {
String level2Str = m2.group("category");
if (null != level2Str) if (null != level2Str)
switch(level2Str) { switch (level2Str) {
case "STDOUT": case "STDOUT":
level = INFO; level = INFO;
break; break;
@ -90,6 +94,7 @@ public enum Level {
level = ERROR; level = ERROR;
break; break;
} }
}
} else { } else {
if (line.contains("[INFO]") || line.contains("[CONFIG]") || line.contains("[FINE]") if (line.contains("[INFO]") || line.contains("[CONFIG]") || line.contains("[FINE]")
|| line.contains("[FINER]") || line.contains("[FINEST]")) || line.contains("[FINER]") || line.contains("[FINEST]"))

View File

@ -1 +0,0 @@
11001