mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-08-27 12:41:43 +00:00
dwa
This commit is contained in:
@@ -256,18 +256,19 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
|
||||
public static void msg(String string) {
|
||||
try {
|
||||
getSender().sendMessage(string);
|
||||
Iris plugin = instance;
|
||||
ComponentLog.logMarkup(
|
||||
plugin,
|
||||
Logger.getLogger("Iris"),
|
||||
logPrefix(plugin),
|
||||
Level.INFO,
|
||||
string,
|
||||
null);
|
||||
} catch (Throwable e) {
|
||||
try {
|
||||
Iris plugin = instance;
|
||||
String tag = plugin == null ? "" : plugin.getTag();
|
||||
ComponentLog.logMarkup(
|
||||
plugin,
|
||||
Logger.getLogger("Iris"),
|
||||
"[Iris] ",
|
||||
Level.INFO,
|
||||
tag + string,
|
||||
null);
|
||||
String plainPrefix = ComponentText.legacy(logPrefix(plugin)).plain();
|
||||
Logger.getLogger("Iris").log(Level.INFO, plainPrefix + IrisLogging.clean(string));
|
||||
} catch (Throwable inner) {
|
||||
System.err.println("[Iris] Failed to emit log message: " + inner.getMessage());
|
||||
inner.printStackTrace(System.err);
|
||||
@@ -561,15 +562,20 @@ public class Iris extends VolmitPlugin implements Listener, ReloadAware {
|
||||
|
||||
private static void diagnostic(Level level, String message) {
|
||||
String line = IrisLogging.clean(message);
|
||||
Iris plugin = instance;
|
||||
ComponentLog.log(
|
||||
instance,
|
||||
plugin,
|
||||
Logger.getLogger("Iris"),
|
||||
"[Iris] ",
|
||||
logPrefix(plugin),
|
||||
level,
|
||||
ComponentText.literal(line),
|
||||
null);
|
||||
}
|
||||
|
||||
private static String logPrefix(Iris plugin) {
|
||||
return plugin == null ? "[Iris] " : plugin.getTag();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return false when the bootstrap was aborted (unsupported server version); the caller
|
||||
* must bail out of onEnable without touching any further setup.
|
||||
|
||||
+13
-14
@@ -13,10 +13,8 @@ import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* Core states a severity on every message it logs and the modded adapters honour it. On Bukkit the same
|
||||
* message used to become a coloured console line, which the server logs at INFO, so no core warning ever
|
||||
* appeared in a WARN-level scan of logs/latest.log - including the orphaned-world-storage reports the
|
||||
* bootstrap replays there specifically for operators to find.
|
||||
* Core states a severity on every message it logs and the modded adapters honour it. Bukkit must preserve
|
||||
* that severity through the shared component logger so diagnostics remain discoverable in logs/latest.log.
|
||||
*/
|
||||
public class IrisDiagnosticLogLevelTest {
|
||||
@Test
|
||||
@@ -26,25 +24,16 @@ public class IrisDiagnosticLogLevelTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void informationalAndDebugMessagesStayOnTheConsolePath() {
|
||||
public void informationalAndDebugMessagesStayOnTheInformationalPath() {
|
||||
assertNull(Iris.diagnosticLevel(LogLevel.INFO));
|
||||
assertNull(Iris.diagnosticLevel(LogLevel.DEBUG));
|
||||
}
|
||||
|
||||
/**
|
||||
* Console sender output reaches the terminal but not the instance's logs/latest.log, which is the only
|
||||
* log most operators read after the fact. A handful of lifecycle lines go to the plugin logger instead.
|
||||
*/
|
||||
@Test
|
||||
public void lifecycleNoticesReachThePluginLoggerAtInfo() {
|
||||
assertEquals(Level.INFO, Iris.diagnosticLevel(LogLevel.NOTICE));
|
||||
}
|
||||
|
||||
/**
|
||||
* A warning raised by the adapter is the same kind of thing as a warning raised by core. Routing one
|
||||
* through the plugin logger and the other through the console sender makes the level depend on which
|
||||
* side of the SPI the call happened to be written on.
|
||||
*/
|
||||
@Test
|
||||
public void adapterSideWarningsCarryTheSameSeverityAsCoreWarnings() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/art/arcane/iris/Iris.java")).replace("\r\n", "\n");
|
||||
@@ -70,6 +59,16 @@ public class IrisDiagnosticLogLevelTest {
|
||||
assertTrue(diagnostic, diagnostic.contains("ComponentText.literal(line)"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void informationalMessagesUseTheSharedComponentLogger() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/art/arcane/iris/Iris.java")).replace("\r\n", "\n");
|
||||
String message = method(source, "public static void msg(String string)");
|
||||
|
||||
assertTrue(message, message.contains("ComponentLog.logMarkup("));
|
||||
assertTrue(message, message.contains("logPrefix(plugin)"));
|
||||
assertFalse(message, message.contains("getSender().sendMessage"));
|
||||
}
|
||||
|
||||
private static String method(String source, String signature) {
|
||||
int start = source.indexOf(signature);
|
||||
assertTrue("method not found: " + signature, start >= 0);
|
||||
|
||||
Reference in New Issue
Block a user