mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Drop debug lines before the platform binds
This commit is contained in:
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);
|
||||
|
||||
Reference in new issue
Block a user