log4jHandler maintainence
This commit is contained in:
@@ -79,14 +79,14 @@ public class MojangDownloadProvider implements DownloadProvider {
|
|||||||
public String injectURL(String baseURL) {
|
public String injectURL(String baseURL) {
|
||||||
if (baseURL == null)
|
if (baseURL == null)
|
||||||
return null;
|
return null;
|
||||||
else if (baseURL.contains("scala-swing") || baseURL.contains("scala-xml") || baseURL.contains("scala-parser-combinators"))
|
//else if (baseURL.contains("scala-swing") || baseURL.contains("scala-xml") || baseURL.contains("scala-parser-combinators"))
|
||||||
return baseURL.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven/");
|
// return baseURL.replace("http://files.minecraftforge.net/maven", "http://ftb.cursecdn.com/FTB2/maven");
|
||||||
else if (baseURL.contains("typesafe") || baseURL.contains("scala"))
|
/*else if (baseURL.contains("typesafe") || baseURL.contains("scala"))
|
||||||
if (isChina)
|
if (isChina)
|
||||||
return baseURL.replace("http://files.minecraftforge.net/maven", "http://maven.aliyun.com/nexus/content/groups/public");
|
return baseURL.replace("http://files.minecraftforge.net/maven", "http://maven.aliyun.com/nexus/content/groups/public");
|
||||||
else
|
else
|
||||||
return baseURL.replace("http://files.minecraftforge.net/maven", "http://repo1.maven.org/maven2");
|
return baseURL.replace("http://files.minecraftforge.net/maven", "http://repo1.maven.org/maven2");
|
||||||
else
|
*/else
|
||||||
return baseURL;
|
return baseURL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ final class Log4jHandler extends Thread {
|
|||||||
private final PipedInputStream inputStream = Lang.invoke(() -> new PipedInputStream(outputStream));
|
private final PipedInputStream inputStream = Lang.invoke(() -> new PipedInputStream(outputStream));
|
||||||
private final AtomicBoolean interrupted = new AtomicBoolean(false);
|
private final AtomicBoolean interrupted = new AtomicBoolean(false);
|
||||||
private final List<String> logs = new LinkedList<>();
|
private final List<String> logs = new LinkedList<>();
|
||||||
|
private boolean broken = false;
|
||||||
|
|
||||||
public Log4jHandler(BiConsumer<String, Log4jLevel> callback) {
|
public Log4jHandler(BiConsumer<String, Log4jLevel> callback) {
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
@@ -95,20 +96,28 @@ final class Log4jHandler extends Thread {
|
|||||||
public Future<?> newLine(String log) {
|
public Future<?> newLine(String log) {
|
||||||
return Schedulers.computation().schedule(() -> {
|
return Schedulers.computation().schedule(() -> {
|
||||||
try {
|
try {
|
||||||
String line = (log + OperatingSystem.LINE_SEPARATOR)
|
String line = log
|
||||||
.replace("<![CDATA[", "")
|
.replace("<![CDATA[", "")
|
||||||
.replace("]]>", "")
|
.replace("]]>", "")
|
||||||
.replace("log4j:Event", "log4j_Event")
|
.replace("log4j:", "log4j_")
|
||||||
.replace("<log4j:Message>", "<log4j_Message><![CDATA[")
|
.replace("<log4j_Message>", "<log4j_Message><![CDATA[")
|
||||||
.replace("</log4j:Message>", "]]></log4j_Message>")
|
.replace("</log4j_Message>", "]]></log4j_Message>")
|
||||||
.replace("log4j:Throwable", "log4j_Throwable");
|
.replace("<log4j_Throwable>", "<log4j_Throwable><![CDATA[")
|
||||||
|
.replace("</log4j_Throwable>", "]]></log4j_Throwable>");
|
||||||
logs.add(line);
|
logs.add(line);
|
||||||
byte[] bytes = line.getBytes(Charsets.UTF_8);
|
if (broken)
|
||||||
|
System.out.println(line);
|
||||||
|
|
||||||
|
byte[] bytes = (line + OperatingSystem.LINE_SEPARATOR).getBytes(Charsets.UTF_8);
|
||||||
outputStream.write(bytes);
|
outputStream.write(bytes);
|
||||||
outputStream.flush();
|
outputStream.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// Ignoring IOException, including read end dead.
|
// Ignoring IOException, including read end dead.
|
||||||
Logging.LOG.log(Level.WARNING, "An error occurred when writing console lines", e);
|
if (!broken) {
|
||||||
|
Logging.LOG.log(Level.WARNING, "An error occurred when writing console lines", e);
|
||||||
|
logs.forEach(System.out::println);
|
||||||
|
broken = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user