chore: clean up logging

This commit is contained in:
Johannes Frohnmeyer 2024-05-05 14:53:07 +02:00
parent 0dc1187d3a
commit 5969d786e4
Signed by: Johannes
GPG Key ID: E76429612C2929F4
10 changed files with 27 additions and 27 deletions

View File

@ -30,7 +30,7 @@ jfMod {
minecraftVersion = "1.20.6"
yarn("build.1")
loaderVersion = "0.15.10"
libJfVersion = "3.15.2"
libJfVersion = "3.15.8"
fabricApiVersion = "0.97.8+1.20.6"
modrinth {

View File

@ -64,7 +64,7 @@ public enum DirFilterEvents implements IEvents {
// New search for fallback path
String newPath = replacement.toFallback(path);
if (newPath.split("/", 3).length != 3) {
Respackopts.LOGGER.error("Directory fallback path MUST be long enough to support representation as identifier (3 segments), but is too short: " + newPath);
Respackopts.LOGGER.error("Directory fallback path MUST be long enough to support representation as identifier (3 segments), but is too short: {0}", newPath);
return;
}
if (!dirFilterAdditive) {
@ -79,16 +79,16 @@ public enum DirFilterEvents implements IEvents {
int prefixSize = replacement.original.prefix().length();
if (prefixSize < searchPrefix.length()) {
if (!searchPrefix.startsWith(replacement.original.prefix())) {
Respackopts.LOGGER.error("Unexpected prefix path " + replacement.original.prefix() + " for search prefix " + searchPrefix + ", skipping");
Respackopts.LOGGER.error("Unexpected prefix path {0} for search prefix {1}, skipping", replacement.original.prefix(), searchPrefix);
return;
}
fallbackDir += searchPrefix.substring(prefixSize);
} else if (!replacement.original.prefix().startsWith(searchPrefix)) {
Respackopts.LOGGER.error("Unexpected prefix path " + replacement.original.prefix() + " for search prefix " + searchPrefix + ", skipping");
Respackopts.LOGGER.error("Unexpected prefix path {0} for search prefix {1}, skipping", replacement.original.prefix(), searchPrefix);
return;
}
if (fallbackDir.split("/", 3).length != 3) {
Respackopts.LOGGER.error("Directory fallback path MUST be long enough to support representation as identifier (3 segments), but is too short: " + fallbackDir);
Respackopts.LOGGER.error("Directory fallback path MUST be long enough to support representation as identifier (3 segments), but is too short: {0}", fallbackDir);
return;
}
ResourcePath rp = new ResourcePath(fallbackDir);
@ -142,7 +142,7 @@ public enum DirFilterEvents implements IEvents {
currentRPOs.add(newRPO);
return currentRPOs;
} catch (IOException e) {
Respackopts.LOGGER.error("Couldn't open dir rpo " + rp, e);
Respackopts.LOGGER.error("Couldn't open dir rpo {0}", rp, e);
}
return parentRPOs;
});

View File

@ -73,7 +73,7 @@ public sealed interface DirRpoResult {
return m.replaceAll(this.fallback.quoted);
}
if (!m.find()) {
Respackopts.LOGGER.error("Attempted conversion to fallback path, but could not find original prefix for: " + original);
Respackopts.LOGGER.error("Attempted conversion to fallback path, but could not find original prefix for: {0}", original);
return original;
}
return m.replaceFirst(this.fallback.quoted);
@ -85,7 +85,7 @@ public sealed interface DirRpoResult {
return m.replaceAll(this.original.quoted);
}
if (!m.find()) {
Respackopts.LOGGER.error("Attempted conversion to original path, but could not find fallback prefix for: " + fallback);
Respackopts.LOGGER.error("Attempted conversion to original path, but could not find fallback prefix for: {0}", fallback);
return fallback;
}
return m.replaceFirst(this.original.quoted);

View File

@ -16,7 +16,7 @@ public class FileDependencyTracker {
public void addDependency(String to, String on) {
if (to.equals(on)) {
if (reportedRecursions.add(to)) Respackopts.LOGGER.warn("Discovered recursive dependency in " + pack + "! If you get a StackOverflowException, please validate your fallbacks for " + to);
if (reportedRecursions.add(to)) Respackopts.LOGGER.warn("Discovered recursive dependency in {0}! If you get a StackOverflowException, please validate your fallbacks for {1}", pack, to);
return;
}
gs(dependencies, to).add(on);

View File

@ -33,7 +33,7 @@ public class FileFallbackProvider {
if (is != null) return is;
}
}
Respackopts.LOGGER.error("Could not determine replacement for " + file);
Respackopts.LOGGER.error("Could not determine replacement for {0}", file);
}
catch (Exception e) {
Respackopts.LOGGER.error("Could not determine replacement for " + file, e);

View File

@ -54,12 +54,12 @@ public class ResourcePackManagerMixin {
Path pack = ((DirectoryResourcePackAccessor) drp).getRoot();
Path parent = pack == null ? null : pack.getParent();
if (parent != null) dataLocation = parent.resolve(pack.getFileName() + Respackopts.FILE_EXTENSION);
else Respackopts.LOGGER.warn("Base path of directory resource pack " + rpi.getId() + " is null. This shouldn't happen!");
else Respackopts.LOGGER.warn("Base path of directory resource pack {0} is null. This shouldn't happen!", rpi.getId());
} else if (rpi instanceof ZipResourcePack zrp) {
File pack = ((ZipFileWrapperAccessor) ((ZipResourcePackAccessor) zrp).getZipFile()).getFile();
Path parent = pack == null ? null : pack.toPath().getParent();
if (parent != null) dataLocation = parent.resolve(pack.getName() + Respackopts.FILE_EXTENSION);
else Respackopts.LOGGER.warn("Base path of zip resource pack " + rpi.getId() + " is null. This shouldn't happen!");
else Respackopts.LOGGER.warn("Base path of zip resource pack {0} is null. This shouldn't happen!", rpi.getId());
}
var conf = rpi.openRoot(Respackopts.ID + ".json5");
@ -94,13 +94,13 @@ public class ResourcePackManagerMixin {
PackMeta conf = GC_PackMeta.deserialize(isr, LibJf.LENIENT_TRANSPORT);
if (!Respackopts.isLegal(conf.id)) {
if (conf.version >= 10) {
Respackopts.LOGGER.error(displayName + " was not loaded as it uses an unsupported pack id: " + conf.id);
Respackopts.LOGGER.error("{0} was not loaded as it uses an unsupported pack id: {1}", displayName, conf.id);
return null;
} else conf.id = Respackopts.sanitizeString(conf.id);
}
if (RespackoptsConfig.debugLogs) Respackopts.LOGGER.info("Discovered pack: " + conf.id);
if (RespackoptsConfig.debugLogs) Respackopts.LOGGER.info("Discovered pack: {0}", conf.id);
if (Respackopts.META_VERSION < conf.version) {
Respackopts.LOGGER.error(displayName + " was not loaded as it specifies a newer respackopts version than is installed");
Respackopts.LOGGER.error("{0} was not loaded as it specifies a newer respackopts version than is installed", displayName);
return null;
}
if (dataLocation == null) dataLocation = Respackopts.FALLBACK_CONF_DIR.resolve(conf.id + ".json");

View File

@ -33,7 +33,7 @@ public class ConfigBranch extends ConfigEntry<Map<String, ConfigEntry<?>>> imple
for (Iterator<String> iterator = getValue().keySet().iterator(); iterator.hasNext(); ) {
String s = iterator.next();
if (!Respackopts.isLegal(s)) {
Respackopts.LOGGER.error("Illegal entry for " + getName() + ", skipping: " + s);
Respackopts.LOGGER.error("Illegal entry for {0}, skipping: {1}", getName(), s);
iterator.remove();
}
}
@ -60,10 +60,10 @@ public class ConfigBranch extends ConfigEntry<Map<String, ConfigEntry<?>>> imple
}
else {
if (mode == ConfigSyncMode.RESPACK_LOAD) {
Respackopts.LOGGER.warn("Type mismatch in config (" + getName() + "), overwriting");
Respackopts.LOGGER.warn("Type mismatch in config ({0}), overwriting", getName());
add(e.getKey(), e.getValue().clone());
} else
Respackopts.LOGGER.warn("Type mismatch in config (" + getName() + "), ignoring");
Respackopts.LOGGER.warn("Type mismatch in config ({0}}), ignoring", getName());
}
}
}
@ -82,7 +82,7 @@ public class ConfigBranch extends ConfigEntry<Map<String, ConfigEntry<?>>> imple
public <T> void add(String name, ConfigEntry<T> val) {
if (version >= 10 && !Respackopts.isLegal(name)) {
Respackopts.LOGGER.error("Illegal entry for " + getName() + ", skipping: " + name);
Respackopts.LOGGER.error("Illegal entry for {0}, skipping: {1}", getName(), name);
return;
}
val.setVersion(version);
@ -125,7 +125,7 @@ public class ConfigBranch extends ConfigEntry<Map<String, ConfigEntry<?>>> imple
super.getValue().forEach((key, value) -> {
if (Respackopts.isLegal(key)) map.put(key, value);
else if (version >= 10) {
Respackopts.LOGGER.error("Illegal key in " + getName() + ", skipping: " + key);
Respackopts.LOGGER.error("Illegal key in {0}, skipping: {1}", getName(), key);
} else map.put(Respackopts.sanitizeString(key), value);
});
return DFinal.of(map);
@ -161,7 +161,7 @@ public class ConfigBranch extends ConfigEntry<Map<String, ConfigEntry<?>>> imple
);
});
builder.executeAfterWrite(cfg -> {
if (RespackoptsConfig.debugLogs) Respackopts.LOGGER.info("GuiFactory SavingRunnable " + agg.get());
if (RespackoptsConfig.debugLogs) Respackopts.LOGGER.info("GuiFactory SavingRunnable {0}", agg.get());
MetaCache.save(new SaveHook.Arguments(agg.get() == PackReloadType.Resource, false, true));
});
builder.setPath(dataLocation);

View File

@ -43,7 +43,7 @@ public abstract class ConfigEntry<T> implements DynamicBase {
public T getValue() {
if (value == null) {
if (defaultValue == null) {
Respackopts.LOGGER.warn("No default value or current value set for entry, returning null in " + getName());
Respackopts.LOGGER.warn("No default value or current value set for entry, returning null in {0}", getName());
return null;
}
value = getDefault();
@ -60,7 +60,7 @@ public abstract class ConfigEntry<T> implements DynamicBase {
public T getDefault() {
if (defaultValue == null) {
defaultValue = getValue();
Respackopts.LOGGER.warn("No default value set for entry, using current in " + getName());
Respackopts.LOGGER.warn("No default value set for entry, using current in {0}", getName());
}
return defaultValue;
}

View File

@ -73,7 +73,7 @@ public class ConfigEnumEntry extends ConfigEntry<String> implements DelegateDyna
for (Iterator<String> iterator = values.iterator(); iterator.hasNext();) {
String value = iterator.next();
if (!Respackopts.isLegal(value)) {
Respackopts.LOGGER.error("Illegal enum entry for " + getName() + ", skipping: " + value);
Respackopts.LOGGER.error("Illegal enum entry for {0}, skipping: {1}", getName(), value);
iterator.remove();
}
}
@ -93,7 +93,7 @@ public class ConfigEnumEntry extends ConfigEntry<String> implements DelegateDyna
setValue(values.get(n.nextValue));
}
else {
Respackopts.LOGGER.error("Could not load default value for enum in " + getName());
Respackopts.LOGGER.error("Could not load default value for enum in {0}", getName());
}
} else nextValue = null;
}

View File

@ -56,7 +56,7 @@ public class MetaCache {
public static void addFromScan(String displayName, String packName, PackMeta meta, Path dataLocation) {
if (Respackopts.META_VERSION > meta.version) {
Respackopts.LOGGER.warn(displayName + " uses an outdated RPO format (" + meta.version + "). Although this is supported, using the latest version (" + Respackopts.META_VERSION + ") is recommended");
Respackopts.LOGGER.warn("{0} uses an outdated RPO format ({1}). Although this is supported, using the latest version ({2}) is recommended", displayName, meta.version, Respackopts.META_VERSION);
}
meta.conf.setVersion(meta.version);
if (meta.version < 5) meta.capabilities.add(PackCapability.DirFilter);
@ -124,7 +124,7 @@ public class MetaCache {
public static void load(CacheKey key) {
if (Files.exists(key.dataLocation())) {
if (RespackoptsConfig.debugLogs)
Respackopts.LOGGER.info("Loading configs for: " + key.displayName());
Respackopts.LOGGER.info("Loading configs for: {0}", key.displayName());
try (Reader reader = Files.newBufferedReader(key.dataLocation())) {
ConfigBranch b = GC_ConfigBranch.deserialize(reader, LibJf.LENIENT_TRANSPORT);
if (PACK_STATES.containsKey(key))