From 5a6c64377a25ece2bc47cbe7e08ee310e0bcb82f Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Sun, 11 Jun 2017 12:24:50 +0800 Subject: [PATCH] Fix console font coloring --- .../org/jackhuang/hmcl/util/log/Level.java | 31 +++++++++++-------- build/kotlin-build/caches/version.txt | 1 - 2 files changed, 18 insertions(+), 14 deletions(-) delete mode 100644 build/kotlin-build/caches/version.txt diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/log/Level.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/log/Level.java index 6ea731135..907435bc5 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/log/Level.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/log/Level.java @@ -47,11 +47,13 @@ public enum Level { return this.level <= level.level; } - public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?[0-9:]+)\\] \\[[^/]+/(?[^\\]]+)\\] \\[(?[^\\]]+)\\]"); + public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?[0-9:]+)\\] \\[[^/]+/(?[^\\]]+)\\]"); + public static final Pattern MINECRAFT_LOGGER_CATEGORY = Pattern.compile("\\[(?[0-9:]+)\\] \\[[^/]+/(?[^\\]]+)\\] \\[(?[^\\]]+)\\]"); 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) { - if (line.startsWith("MC:")) line = line.substring("MC:".length()); + if (line.startsWith("MC:")) + line = line.substring("MC:".length()); Level level = preLevel; Matcher m = MINECRAFT_LOGGER.matcher(line); if (m.find()) { @@ -80,19 +82,22 @@ public enum Level { default: break; } - String level2Str = m.group("category"); - if (null != level2Str) - switch(level2Str) { - case "STDOUT": - level = INFO; - break; - case "STDERR": - level = ERROR; - break; - } + Matcher m2 = MINECRAFT_LOGGER_CATEGORY.matcher(line); + if (m2.find()) { + String level2Str = m2.group("category"); + if (null != level2Str) + switch (level2Str) { + case "STDOUT": + level = INFO; + break; + case "STDERR": + level = ERROR; + break; + } + } } else { if (line.contains("[INFO]") || line.contains("[CONFIG]") || line.contains("[FINE]") - || line.contains("[FINER]") || line.contains("[FINEST]")) + || line.contains("[FINER]") || line.contains("[FINEST]")) level = INFO; if (line.contains("[SEVERE]") || line.contains("[STDERR]")) level = ERROR; diff --git a/build/kotlin-build/caches/version.txt b/build/kotlin-build/caches/version.txt deleted file mode 100644 index 01aabacbf..000000000 --- a/build/kotlin-build/caches/version.txt +++ /dev/null @@ -1 +0,0 @@ -11001 \ No newline at end of file