Drop debug lines before the platform binds

This commit is contained in:
piexel committed 2026-11-18 22:07:57 +01:00
1 parent 7c31231a77
commit 3b9cb4ce91
2 files changed
+28

No files matched your search

@@ -6,6 +6,9 @@ import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@@ -71,6 +74,22 @@ public class IrisLoggingTest {
assertEquals("chunk=3,7", messages.getFirst());
}
@Test
public void debugIsDroppedWhenNoPlatformCanSayDebugIsOn() {
IrisPlatforms.unbind();
ByteArrayOutputStream captured = new ByteArrayOutputStream();
PrintStream originalOut = System.out;
System.setOut(new PrintStream(captured, true, StandardCharsets.UTF_8));
try {
IrisLogging.debug("Loader<Biome> iload plains");
IrisLogging.info("visible");
} finally {
System.setOut(originalOut);
}
assertEquals("[Iris/INFO] visible" + System.lineSeparator(), captured.toString(StandardCharsets.UTF_8));
}
@Test
public void contextualReportUsesThePlatformReporterWithoutADuplicateLogLine() {
RuntimeException failure = new RuntimeException("broken");
@@ -222,6 +222,11 @@ public final class IrisLogging {
return ONCE_KEYS.add(key == null ? "null" : key);
}
/**
* Without a bound platform the debug setting cannot be read, so debug lines are dropped as if it were off:
* the Paper bootstrap runs pack loading before the plugin binds, and would otherwise print every loader
* line to the console.
*/
private static void emit(LogLevel level, String message) {
LogLevel target = level == null ? LogLevel.INFO : level;
if (IrisPlatforms.isBound()) {
@@ -229,6 +234,10 @@ public final class IrisLogging {
return;
}
if (target == LogLevel.DEBUG) {
return;
}
String output = clean(message);
if (target == LogLevel.WARN || target == LogLevel.ERROR) {
System.err.println("[Iris/" + target + "] " + output);