mirror of
https://github.com/SKCraft/Launcher.git
synced 2025-01-06 19:18:27 +01:00
Add embedded logging configs
Minecraft's default logging configs output XML to stdout, because the modern launcher parses it to provide a "nicer" console. We don't do that, so this commit adds embedded versions of the logging configs which just output log lines normally.
This commit is contained in:
parent
94ae835b42
commit
6f7624a66d
@ -34,8 +34,11 @@ import lombok.extern.java.Log;
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -274,18 +277,28 @@ public abstract class BaseUpdater {
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch logging config
|
||||
// Use our custom logging config depending on what the manifest specifies
|
||||
if (versionManifest.getLogging() != null) {
|
||||
VersionManifest.LoggingConfig config = versionManifest.getLogging().getClient();
|
||||
|
||||
VersionManifest.Artifact file = config.getFile();
|
||||
File targetFile = new File(librariesDir, file.getId());
|
||||
InputStream embeddedConfig = Launcher.class.getResourceAsStream("logging/" + file.getId());
|
||||
|
||||
if (!targetFile.exists() || !Objects.equals(config.getFile().getHash(), FileUtils.getShaHash(targetFile))) {
|
||||
if (embeddedConfig == null) {
|
||||
// No embedded config, just use whatever the server gives us
|
||||
File tempFile = installer.getDownloader().download(url(file.getUrl()), file.getHash(), file.getSize(), file.getId());
|
||||
|
||||
log.info("Downloading logging config " + file.getId() + " from " + file.getUrl());
|
||||
installer.queue(new FileMover(tempFile, targetFile));
|
||||
} else if (!targetFile.exists() || FileUtils.getShaHash(targetFile).equals(file.getHash())) {
|
||||
// Use our embedded replacement
|
||||
|
||||
Path tempFile = installer.getTempDir().toPath().resolve(file.getId());
|
||||
Files.copy(embeddedConfig, tempFile);
|
||||
|
||||
log.info("Substituting embedded logging config " + file.getId());
|
||||
installer.queue(new FileMover(tempFile.toFile(), targetFile));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n"/>
|
||||
</Console>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg{nolookups}%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy/>
|
||||
<OnStartupTriggeringPolicy/>
|
||||
</Policies>
|
||||
</RollingRandomAccessFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<filters>
|
||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
</filters>
|
||||
<AppenderRef ref="SysOut"/>
|
||||
<AppenderRef ref="File"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="WARN">
|
||||
<Appenders>
|
||||
<Console name="SysOut" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n"/>
|
||||
</Console>
|
||||
<RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
|
||||
<PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n"/>
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy/>
|
||||
<OnStartupTriggeringPolicy/>
|
||||
</Policies>
|
||||
</RollingRandomAccessFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="info">
|
||||
<filters>
|
||||
<MarkerFilter marker="NETWORK_PACKETS" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
<RegexFilter regex=".*\$\{[^}]*\}.*" onMatch="DENY" onMismatch="NEUTRAL"/>
|
||||
</filters>
|
||||
<AppenderRef ref="SysOut"/>
|
||||
<AppenderRef ref="File"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
Loading…
Reference in New Issue
Block a user