This commit is contained in:
Brian Neumann-Fopiano
2026-08-20 10:59:17 -04:00
parent fec655def4
commit 5cacf6d435
62 changed files with 4893 additions and 278 deletions
@@ -35,9 +35,13 @@ public final class ModdedIrisLog {
LogLevel target = level == null ? LogLevel.INFO : level;
switch (target) {
case DEBUG -> debug(message);
case INFO -> info(message);
case WARN -> warn(message);
case ERROR -> error(message);
// INFO, NOTICE, and any level added later. This is a switch statement, so the compiler does not
// check it for exhaustiveness and a missing arm would drop the message silently. The modded
// loaders have one logger, so a lifecycle notice is already in the file the server writes; the
// level only differs on Bukkit, where INFO goes to a console sender instead.
default -> info(message);
}
}
@@ -0,0 +1,27 @@
package art.arcane.iris.modded;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.Assert.assertTrue;
/**
* The level router is a switch statement, which the compiler does not check for exhaustiveness. A level added
* to {@link art.arcane.iris.spi.LogLevel} with no arm here would compile and then drop every message at that
* level without a trace, so the fallback arm is what keeps a new level visible on the modded loaders.
*/
public class ModdedIrisLogLevelCoverageTest {
@Test
public void everyLogLevelReachesTheLoggerIncludingOnesAddedLater() throws IOException {
String source = Files.readString(Path.of(System.getProperty("iris.moddedCommonSources"),
"art/arcane/iris/modded/ModdedIrisLog.java"));
int router = source.indexOf("public static void log(LogLevel level, String message)");
assertTrue("log(LogLevel, String) not found", router >= 0);
String body = source.substring(router, source.indexOf("public static void debug(", router));
assertTrue(body, body.contains("default -> info(message);"));
}
}