mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-03-31 18:10:26 +08:00
add STDOUT & STDERR highlight
This commit is contained in:
parent
a8bc4eb352
commit
4fdafecf77
@ -19,17 +19,17 @@ import java.util.jar.JarFile
|
||||
import java.util.jar.Pack200
|
||||
import java.util.zip.GZIPOutputStream
|
||||
import java.security.MessageDigest
|
||||
import java.util.jar.JarOutputStream
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
plugins {
|
||||
id "edu.sc.seis.macAppBundle" version "2.1.6"
|
||||
id "me.tatarka.retrolambda" version "3.5.0"
|
||||
id 'edu.sc.seis.launch4j' version '2.3.0'
|
||||
id "org.jetbrains.kotlin.jvm" version "1.1.2-2"
|
||||
}
|
||||
|
||||
import java.util.jar.JarOutputStream
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
if (!hasProperty('mainClass')) {
|
||||
ext.mainClass = 'org.jackhuang.hmcl.Main'
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
plugins {
|
||||
id "me.tatarka.retrolambda" version "3.5.0"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.1.2-2"
|
||||
}
|
||||
|
||||
if (System.getenv("BUILD_NUMBER") != null)
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
plugins {
|
||||
id "me.tatarka.retrolambda" version "3.5.0"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.1.2-2"
|
||||
}
|
||||
|
||||
if (System.getenv("BUILD_NUMBER") != null)
|
||||
|
@ -47,7 +47,7 @@ public enum Level {
|
||||
return this.level <= level.level;
|
||||
}
|
||||
|
||||
public static final Pattern MINECRAFT_LOGGER = Pattern.compile("\\[(?<timestamp>[0-9:]+)\\] \\[[^/]+/(?<level>[^\\]]+)\\]");
|
||||
public static final Pattern MINECRAFT_LOGGER = 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 Level guessLevel(String line, Level preLevel) {
|
||||
@ -58,26 +58,36 @@ public enum Level {
|
||||
String levelStr = m.group("level");
|
||||
if (null != levelStr)
|
||||
switch (levelStr) {
|
||||
case "INFO":
|
||||
level = INFO;
|
||||
break;
|
||||
case "WARN":
|
||||
level = WARN;
|
||||
break;
|
||||
case "ERROR":
|
||||
level = ERROR;
|
||||
break;
|
||||
case "FATAL":
|
||||
level = FATAL;
|
||||
break;
|
||||
case "TRACE":
|
||||
level = TRACE;
|
||||
break;
|
||||
case "DEBUG":
|
||||
level = DEBUG;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case "INFO":
|
||||
level = INFO;
|
||||
break;
|
||||
case "WARN":
|
||||
level = WARN;
|
||||
break;
|
||||
case "ERROR":
|
||||
level = ERROR;
|
||||
break;
|
||||
case "FATAL":
|
||||
level = FATAL;
|
||||
break;
|
||||
case "TRACE":
|
||||
level = TRACE;
|
||||
break;
|
||||
case "DEBUG":
|
||||
level = DEBUG;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
String level2Str = m.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]")
|
||||
@ -94,10 +104,10 @@ public enum Level {
|
||||
return FATAL;
|
||||
|
||||
if (line.contains("Exception in thread")
|
||||
|| line.matches("\\s+at " + JAVA_SYMBOL)
|
||||
|| line.matches("Caused by: " + JAVA_SYMBOL)
|
||||
|| line.matches("([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$]?[a-zA-Z\\d_$]*(Exception|Error|Throwable)")
|
||||
|| line.matches("... \\d+ more$"))
|
||||
|| line.matches("\\s+at " + JAVA_SYMBOL)
|
||||
|| line.matches("Caused by: " + JAVA_SYMBOL)
|
||||
|| line.matches("([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$]?[a-zA-Z\\d_$]*(Exception|Error|Throwable)")
|
||||
|| line.matches("... \\d+ more$"))
|
||||
return ERROR;
|
||||
return preLevel.level < level.level ? preLevel : level;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
plugins {
|
||||
id "me.tatarka.retrolambda" version "3.5.0"
|
||||
id "org.jetbrains.kotlin.jvm" version "1.1.2-2"
|
||||
}
|
||||
|
||||
if (System.getenv("BUILD_NUMBER") != null)
|
||||
|
@ -27,6 +27,7 @@ apply plugin: 'maven'
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.code.gson:gson:2.2.4' // Apache License 2.0
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:1.1.2"
|
||||
}
|
||||
|
||||
task sourcesJar(type: Jar, dependsOn: classes, description: 'Creates a jar from the source files.') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user