From 3c55b46ca03f5cd7f28c01cfed779e55129bf1e3 Mon Sep 17 00:00:00 2001 From: cpw Date: Sat, 26 Jan 2019 22:18:28 -0500 Subject: [PATCH] Big cleanup of logging. Might do some tweaks of the userdev logging, but this should be good for vanilla.. Signed-off-by: cpw --- .../minecraftforge/event/RegistryEvent.java | 8 +++++++ .../fml/AutomaticEventSubscriber.java | 2 +- .../net/minecraftforge/fml/LaunchTesting.java | 8 +++---- .../java/net/minecraftforge/fml/ModList.java | 4 ++-- .../event/lifecycle/ModLifecycleEvent.java | 8 ++++++- .../fml/javafmlmod/FMLModContainer.java | 4 ++-- .../minecraftforge/registries/GameData.java | 6 +++-- .../registries/ObjectHolderRegistry.java | 4 +++- src/main/resources/log4j2.xml | 24 ++++++++++++------- 9 files changed, 46 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/minecraftforge/event/RegistryEvent.java b/src/main/java/net/minecraftforge/event/RegistryEvent.java index bb60fec2b..30ccc5507 100644 --- a/src/main/java/net/minecraftforge/event/RegistryEvent.java +++ b/src/main/java/net/minecraftforge/event/RegistryEvent.java @@ -45,6 +45,10 @@ public class RegistryEvent> extends GenericEven */ public static class NewRegistry extends net.minecraftforge.eventbus.api.Event { + @Override + public String toString() { + return "RegistryEvent.NewRegistry"; + } } /** @@ -80,6 +84,10 @@ public class RegistryEvent> extends GenericEven return name; } + @Override + public String toString() { + return "RegistryEvent.Register<"+getName()+">"; + } } public static class MissingMappings> extends RegistryEvent diff --git a/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java b/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java index 42823d70e..e1499155d 100644 --- a/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java +++ b/src/main/java/net/minecraftforge/fml/AutomaticEventSubscriber.java @@ -66,7 +66,7 @@ public class AutomaticEventSubscriber if (Objects.equals(mod.getModId(), modId) && sides.contains(FMLEnvironment.dist)) { try { - LOGGER.info(LOADING, "Auto-subscribing {} to {}", ad.getClassType().getClassName(), busTarget); + LOGGER.debug(LOADING, "Auto-subscribing {} to {}", ad.getClassType().getClassName(), busTarget); busTarget.bus().get().register(Class.forName(ad.getClassType().getClassName(), true, loader)); } catch (ClassNotFoundException e) diff --git a/src/main/java/net/minecraftforge/fml/LaunchTesting.java b/src/main/java/net/minecraftforge/fml/LaunchTesting.java index a5f8d791d..191f4ca77 100644 --- a/src/main/java/net/minecraftforge/fml/LaunchTesting.java +++ b/src/main/java/net/minecraftforge/fml/LaunchTesting.java @@ -37,15 +37,15 @@ public class LaunchTesting public static void main(String... args) throws InterruptedException { Configurator.setRootLevel(Level.DEBUG); - final MarkerFilter classloadingFilter = MarkerFilter.createFilter("CLASSLOADING", Filter.Result.DENY, Filter.Result.NEUTRAL); - final MarkerFilter launchpluginFilter = MarkerFilter.createFilter("LAUNCHPLUGIN", Filter.Result.DENY, Filter.Result.NEUTRAL); +// final MarkerFilter classloadingFilter = MarkerFilter.createFilter("CLASSLOADING", Filter.Result.DENY, Filter.Result.NEUTRAL); +// final MarkerFilter launchpluginFilter = MarkerFilter.createFilter("LAUNCHPLUGIN", Filter.Result.DENY, Filter.Result.NEUTRAL); final MarkerFilter axformFilter= MarkerFilter.createFilter("AXFORM", Filter.Result.DENY, Filter.Result.NEUTRAL); final MarkerFilter eventbusFilter = MarkerFilter.createFilter("EVENTBUS", Filter.Result.DENY, Filter.Result.NEUTRAL); final MarkerFilter distxformFilter = MarkerFilter.createFilter("DISTXFORM", Filter.Result.DENY, Filter.Result.NEUTRAL); // final MarkerFilter scannerFilter = MarkerFilter.createFilter("SCAN", Filter.Result.DENY, Filter.Result.NEUTRAL); final LoggerContext logcontext = LoggerContext.getContext(false); - logcontext.getConfiguration().addFilter(classloadingFilter); - logcontext.getConfiguration().addFilter(launchpluginFilter); +// logcontext.getConfiguration().addFilter(classloadingFilter); +// logcontext.getConfiguration().addFilter(launchpluginFilter); // logcontext.getConfiguration().addFilter(axformFilter); // logcontext.getConfiguration().addFilter(eventbusFilter); // logcontext.getConfiguration().addFilter(distxformFilter); diff --git a/src/main/java/net/minecraftforge/fml/ModList.java b/src/main/java/net/minecraftforge/fml/ModList.java index ff5f04ae6..8c9af833e 100644 --- a/src/main/java/net/minecraftforge/fml/ModList.java +++ b/src/main/java/net/minecraftforge/fml/ModList.java @@ -94,13 +94,13 @@ public class ModList } private void dispatchSynchronousEvent(LifecycleEventProvider.LifecycleEvent lifecycleEvent, final Consumer> errorHandler) { - LOGGER.info(LOADING, "Dispatching synchronous event {}", lifecycleEvent); + LOGGER.debug(LOADING, "Dispatching synchronous event {}", lifecycleEvent); FMLLoader.getLanguageLoadingProvider().forEach(lp->lp.consumeLifecycleEvent(()->lifecycleEvent)); this.mods.forEach(m->m.transitionState(lifecycleEvent, errorHandler)); FMLLoader.getLanguageLoadingProvider().forEach(lp->lp.consumeLifecycleEvent(()->lifecycleEvent)); } private void dispatchParallelEvent(LifecycleEventProvider.LifecycleEvent lifecycleEvent, final Consumer> errorHandler) { - LOGGER.info(LOADING, "Dispatching parallel event {}", lifecycleEvent); + LOGGER.debug(LOADING, "Dispatching parallel event {}", lifecycleEvent); FMLLoader.getLanguageLoadingProvider().forEach(lp->lp.consumeLifecycleEvent(()->lifecycleEvent)); DeferredWorkQueue.clear(); try diff --git a/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java b/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java index 0eaa04645..22d45172c 100644 --- a/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java +++ b/src/main/java/net/minecraftforge/fml/event/lifecycle/ModLifecycleEvent.java @@ -23,6 +23,7 @@ import net.minecraftforge.eventbus.api.Event; import net.minecraftforge.fml.InterModComms; import net.minecraftforge.fml.ModContainer; +import java.util.Arrays; import java.util.function.Predicate; import java.util.stream.Stream; @@ -42,7 +43,7 @@ public class ModLifecycleEvent extends Event public final String description() { String cn = getClass().getName(); - return cn.substring(cn.lastIndexOf('.')+4,cn.length()-5); + return cn.substring(cn.lastIndexOf('.')+1); } public Stream getIMCStream() { @@ -52,4 +53,9 @@ public class ModLifecycleEvent extends Event public Stream getIMCStream(Predicate methodFilter) { return InterModComms.getMessages(this.container.getModId(), methodFilter); } + + @Override + public String toString() { + return description(); + } } diff --git a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java index 2630fb8b7..5439f1092 100644 --- a/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java +++ b/src/main/java/net/minecraftforge/fml/javafmlmod/FMLModContainer.java @@ -98,11 +98,11 @@ public class FMLModContainer extends ModContainer private void fireEvent(LifecycleEventProvider.LifecycleEvent lifecycleEvent) { final Event event = lifecycleEvent.getOrBuildEvent(this); - LOGGER.info(LOADING, "Firing event for modid {} : {}", this.getModId(), event.getClass().getName()); + LOGGER.debug(LOADING, "Firing event for modid {} : {}", this.getModId(), event); try { eventBus.post(event); - LOGGER.debug(LOADING, "Fired event for modid {} : {}", this.getModId(), event.getClass().getName()); + LOGGER.debug(LOADING, "Fired event for modid {} : {}", this.getModId(), event); } catch (Throwable e) { diff --git a/src/main/java/net/minecraftforge/registries/GameData.java b/src/main/java/net/minecraftforge/registries/GameData.java index 9519fb3dd..5e6a00a3c 100644 --- a/src/main/java/net/minecraftforge/registries/GameData.java +++ b/src/main/java/net/minecraftforge/registries/GameData.java @@ -65,6 +65,8 @@ import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; +import static net.minecraftforge.fml.Logging.CORE; + /** * INTERNAL ONLY * MODDERS SHOULD HAVE NO REASON TO USE THIS CLASS @@ -809,9 +811,9 @@ public class GameData if (i==keysSize-1) lifecycleEventProvider.changeProgression(LifecycleEventProvider.LifecycleEvent.Progression.NEXT); eventDispatcher.accept(lifecycleEventProvider); reg.freeze(); - LOGGER.info("{} Applying holder lookups", rl.toString()); + LOGGER.debug(CORE,"Applying holder lookups: {}", rl.toString()); ObjectHolderRegistry.applyObjectHolders(rl::equals); - LOGGER.info("{} Holder lookups applied", rl.toString()); + LOGGER.debug(CORE,"Holder lookups applied: {}", rl.toString()); } } diff --git a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java index 6cd0a7465..7d8c66a07 100644 --- a/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java +++ b/src/main/java/net/minecraftforge/registries/ObjectHolderRegistry.java @@ -45,6 +45,8 @@ import org.apache.logging.log4j.Logger; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; +import static net.minecraftforge.fml.Logging.CORE; + /** * Internal registry for tracking {@link ObjectHolder} references */ @@ -87,7 +89,7 @@ public class ObjectHolderRegistry public static void findObjectHolders() { - LOGGER.info("Processing ObjectHolder annotations"); + LOGGER.debug(CORE,"Processing ObjectHolder annotations"); final List annotations = ModList.get().getAllScanData().stream() .map(ModFileScanData::getAnnotations) .flatMap(Collection::stream) diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml index 1e2fe026b..431d9a589 100644 --- a/src/main/resources/log4j2.xml +++ b/src/main/resources/log4j2.xml @@ -3,31 +3,31 @@ - + - - + + - + - - + + - + - + @@ -41,7 +41,13 @@ - + + + + + + +