mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-03 19:51:49 +00:00
Show each pack's module list once, not on every pack load
This commit is contained in:
1 parent
da77a04fd0
commit
5ea1a69190
2 files changed
+27
-2
No files matched your search
@@ -26,6 +26,8 @@ import com.volmit.host.ModuleLogs;
|
|||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes IrisApi's pack load log, the module summary and the missing-classes warning, to Iris's log.
|
* Writes IrisApi's pack load log, the module summary and the missing-classes warning, to Iris's log.
|
||||||
@@ -37,9 +39,23 @@ final class IrisApiLogger implements System.Logger {
|
|||||||
private static final ModuleLog HOST_LOG = ModuleLogs.labelled(HOST_MODULE_LABEL, new IrisApiLogger(HOST_MODULE_LABEL));
|
private static final ModuleLog HOST_LOG = ModuleLogs.labelled(HOST_MODULE_LABEL, new IrisApiLogger(HOST_MODULE_LABEL));
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
|
private final Set<String> shownMessages;
|
||||||
|
|
||||||
IrisApiLogger(String name) {
|
IrisApiLogger(String name) {
|
||||||
|
this(name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IrisApiLogger(String name, Set<String> shownMessages) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.shownMessages = shownMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A log that shows each distinct message once and later copies only as debug lines. Iris loads the same pack many
|
||||||
|
* times while starting, and its module summary only says something new when the modules change.
|
||||||
|
*/
|
||||||
|
static IrisApiLogger showingEachMessageOnce(String name) {
|
||||||
|
return new IrisApiLogger(name, ConcurrentHashMap.newKeySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The log of Iris itself, for the world code that is not any module's. */
|
/** The log of Iris itself, for the world code that is not any module's. */
|
||||||
@@ -83,7 +99,11 @@ final class IrisApiLogger implements System.Logger {
|
|||||||
emit(level, parameters == null || parameters.length == 0 ? format : MessageFormat.format(format, parameters));
|
emit(level, parameters == null || parameters.length == 0 ? format : MessageFormat.format(format, parameters));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void emit(Level level, String message) {
|
private void emit(Level level, String message) {
|
||||||
|
if (isRepeat(message)) {
|
||||||
|
IrisLogging.debug(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case ERROR -> IrisLogging.error(message);
|
case ERROR -> IrisLogging.error(message);
|
||||||
case WARNING -> IrisLogging.warn(message);
|
case WARNING -> IrisLogging.warn(message);
|
||||||
@@ -91,4 +111,9 @@ final class IrisApiLogger implements System.Logger {
|
|||||||
default -> IrisLogging.debug(message);
|
default -> IrisLogging.debug(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isRepeat(String message) {
|
||||||
|
boolean reachesPlatformLog = IrisPlatforms.isBound();
|
||||||
|
return shownMessages != null && reachesPlatformLog && !shownMessages.add(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -127,7 +127,7 @@ public final class IrisModuleHost {
|
|||||||
.reservingFolders(IrisData.ownFolderNames().toArray(String[]::new))
|
.reservingFolders(IrisData.ownFolderNames().toArray(String[]::new))
|
||||||
.bundlingJars(bundledJars())
|
.bundlingJars(bundledJars())
|
||||||
.copyingJarsTo(jarCopyRoot())
|
.copyingJarsTo(jarCopyRoot())
|
||||||
.loggingTo(new IrisApiLogger(PackModules.class.getName()));
|
.loggingTo(IrisApiLogger.showingEachMessageOnce(PackModules.class.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user