More logging tweaks, including some aimed at userdev.

`forge.logging.markers=<LIST OF MARKERS>` will enable markers.

Signed-off-by: cpw <[email protected]>
This commit is contained in:
cpw committed 2019-01-27 00:06:57 -05:00
1 parent 3c55b46ca0
commit 0a11ffb827
14 files changed
+79 -78

No files matched your search

@@ -20,6 +20,7 @@
package net.minecraftforge.common;
import static net.minecraftforge.fml.Logging.CORE;
import static net.minecraftforge.fml.loading.LogMarkers.FORGEMOD;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -281,11 +282,11 @@ public class ForgeConfig
private static void loadFrom(final Path configRoot) {
Path configFile = configRoot.resolve("forge.toml");
spec.setConfigFile(configFile);
LogManager.getLogger().debug(CORE, "Loaded Forge config from {}", configFile);
LogManager.getLogger().debug(FORGEMOD, "Loaded Forge config from {}", configFile);
configFile = configRoot.resolve("forge_chunks.toml");
chunk_spec.setConfigFile(configFile);
LogManager.getLogger().debug(CORE, "Loaded Forge Chunk config from {}", configFile);
LogManager.getLogger().debug(FORGEMOD, "Loaded Forge Chunk config from {}", configFile);
}
public static void load() {
@@ -74,7 +74,7 @@ public class ForgeMod implements WorldPersistenceHooks.WorldPersistenceHook
public ForgeMod()
{
LOGGER.info("Forge mod loading, version {}, for MC {} with MCP {}", ForgeVersion.getVersion(), MCPVersion.getMCVersion(), MCPVersion.getMCPVersion());
LOGGER.info(FORGEMOD,"Forge mod loading, version {}, for MC {} with MCP {}", ForgeVersion.getVersion(), MCPVersion.getMCVersion(), MCPVersion.getMCPVersion());
INSTANCE = this;
WorldPersistenceHooks.addHook(this);
WorldPersistenceHooks.addHook(new FMLWorldPersistenceHook());
@@ -34,6 +34,8 @@ import java.util.Map;
import java.util.Objects;
import java.util.function.BiConsumer;
import static net.minecraftforge.fml.Logging.CORE;
public class ForgeI18n {
private static final Logger LOGGER = LogManager.getLogger();
private static Map<String,String> i18n;
@@ -80,7 +82,7 @@ public class ForgeI18n {
}
public static void loadLanguageData(final Map<String, String> properties) {
LOGGER.debug("Loading I18N data entries: {}", properties.size());
LOGGER.debug(CORE,"Loading I18N data entries: {}", properties.size());
i18n = properties;
}
@@ -22,6 +22,7 @@ package net.minecraftforge.fml;
import com.google.common.base.Strings;
import com.google.common.collect.ObjectArrays;
import cpw.mods.modlauncher.Launcher;
import net.minecraftforge.fml.loading.StringUtils;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LoggerContext;
@@ -30,27 +31,16 @@ import org.apache.logging.log4j.core.filter.MarkerFilter;
import java.io.File;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Locale;
import java.util.Objects;
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 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(axformFilter);
// logcontext.getConfiguration().addFilter(eventbusFilter);
// logcontext.getConfiguration().addFilter(distxformFilter);
// logcontext.getConfiguration().addFilter(scannerFilter);
logcontext.updateLoggers();
final String markerselection = System.getProperty("forge.logging.markers", "");
Arrays.stream(markerselection.split(",")).forEach(marker-> System.setProperty("forge.logging.marker."+ marker.toLowerCase(Locale.ROOT), "ACCEPT"));
String assets = System.getenv().getOrDefault("assetDirectory", "assets");
String target = System.getenv().get("target");
@@ -50,7 +50,7 @@ public class FMLModContainer extends ModContainer
public FMLModContainer(IModInfo info, String className, ClassLoader modClassLoader, ModFileScanData modFileScanResults)
{
super(info);
LOGGER.debug("Creating FMLModContainer instance for {} with classLoader {} & {}", className, modClassLoader, getClass().getClassLoader());
LOGGER.debug(LOADING,"Creating FMLModContainer instance for {} with classLoader {} & {}", className, modClassLoader, getClass().getClassLoader());
this.scanResults = modFileScanResults;
triggerMap.put(ModLoadingStage.CONSTRUCT, dummy().andThen(this::beforeEvent).andThen(this::constructMod).andThen(this::afterEvent));
triggerMap.put(ModLoadingStage.CREATE_REGISTRIES, dummy().andThen(this::beforeEvent).andThen(this::fireEvent).andThen(this::afterEvent));
@@ -29,9 +29,11 @@ import java.util.Map.Entry;
import javax.annotation.Nonnull;
import net.minecraftforge.fml.ModThreadContext;
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter;
import org.apache.commons.lang3.Validate;
import java.util.Set;
import java.util.stream.Collectors;
import com.google.common.base.Preconditions;
import com.google.common.collect.ArrayListMultimap;
@@ -56,6 +58,7 @@ import org.apache.logging.log4j.MarkerManager;
public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRegistryInternal<V>, IForgeRegistryModifiable<V>
{
public static Marker REGISTRIES = MarkerManager.getMarker("REGISTRIES");
private static Marker REGISTRYDUMP = MarkerManager.getMarker("REGISTRYDUMP");
private static Logger LOGGER = LogManager.getLogger();
private final RegistryManager stage;
private final BiMap<Integer, V> ids = HashBiMap.create();
@@ -625,13 +628,12 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
void dump(ResourceLocation name)
{
List<Integer> ids = Lists.newArrayList();
getKeys().forEach(n -> ids.add(getID(n)));
Collections.sort(ids);
LOGGER.trace(REGISTRIES, "Registry Name : {}", name);
ids.forEach(id -> LOGGER.trace(REGISTRIES," Registry: {} {} {}", id, getKey(getValue(id)), getValue(id)));
LOGGER.debug(REGISTRYDUMP, ()-> new AdvancedLogMessageAdapter(sb-> {
sb.append("Registry Name: ").append(name).append('\n');
getKeys().stream().map(this::getID).sorted().forEach(id ->
sb.append("\tEntry: ").append(id).append(", ").
append(getKey(getValue(id))).append(", ").append(getValue(id)).append('\n'));
}));
}
public void loadIds(Map<ResourceLocation, Integer> ids, Map<ResourceLocation, String> overrides, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remapped, ForgeRegistry<V> old, ResourceLocation name)
@@ -47,6 +47,7 @@ import net.minecraftforge.fml.StartupQuery;
import net.minecraftforge.fml.common.EnhancedRuntimeException;
import net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession;
import net.minecraftforge.fml.common.thread.EffectiveSide;
import net.minecraftforge.fml.loading.AdvancedLogMessageAdapter;
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -66,6 +67,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import static net.minecraftforge.fml.Logging.CORE;
import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
/**
* INTERNAL ONLY
@@ -74,7 +76,6 @@ import static net.minecraftforge.fml.Logging.CORE;
public class GameData
{
private static final Logger LOGGER = LogManager.getLogger();
private static final Marker GD = MarkerManager.getMarker("GAMEDATA");
public static final ResourceLocation BLOCKS = new ResourceLocation("minecraft:blocks");
public static final ResourceLocation ITEMS = new ResourceLocation("minecraft:items");
@@ -111,9 +112,9 @@ public class GameData
@SuppressWarnings("unchecked")
public static void init()
{
if ( DISABLE_VANILLA_REGISTRIES)
if (DISABLE_VANILLA_REGISTRIES)
{
LOGGER.warn(GD, "DISABLING VANILLA REGISTRY CREATION AS PER SYSTEM VARIABLE SETTING! forge.disableVanillaGameData");
LOGGER.warn(REGISTRIES, "DISABLING VANILLA REGISTRY CREATION AS PER SYSTEM VARIABLE SETTING! forge.disableVanillaGameData");
return;
}
if (hasInit)
@@ -190,7 +191,7 @@ public class GameData
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void vanillaSnapshot()
{
LOGGER.debug("Creating vanilla freeze snapshot");
LOGGER.debug(REGISTRIES, "Creating vanilla freeze snapshot");
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
@@ -203,13 +204,13 @@ public class GameData
});
RegistryManager.VANILLA.registries.forEach(LOCK_VANILLA);
RegistryManager.ACTIVE.registries.forEach(LOCK_VANILLA);
LOGGER.debug("Vanilla freeze snapshot created");
LOGGER.debug(REGISTRIES, "Vanilla freeze snapshot created");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void freezeData()
{
LOGGER.debug(GD, "Freezing registries");
LOGGER.debug(REGISTRIES, "Freezing registries");
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
@@ -223,12 +224,13 @@ public class GameData
RegistryManager.ACTIVE.registries.forEach((name, reg) -> {
reg.freeze();
reg.bake();
reg.dump(name);
});
// the id mapping is finalized, no ids actually changed but this is a good place to tell everyone to 'bake' their stuff.
//Loader.instance().fireRemapEvent(ImmutableMap.of(), true);
LOGGER.debug(GD, "All registries frozen");
LOGGER.debug(REGISTRIES, "All registries frozen");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -236,12 +238,12 @@ public class GameData
{
if (RegistryManager.FROZEN.registries.isEmpty())
{
LOGGER.warn(GD, "Can't revert to frozen GameData state without freezing first.");
LOGGER.warn(REGISTRIES, "Can't revert to frozen GameData state without freezing first.");
return;
}
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.resetDelegates());
LOGGER.debug(GD, "Reverting to frozen data state.");
LOGGER.debug(REGISTRIES, "Reverting to frozen data state.");
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
@@ -253,16 +255,16 @@ public class GameData
ObjectHolderRegistry.applyObjectHolders();
// the id mapping has reverted, ensure we sync up the object holders
LOGGER.debug("Frozen state restored.");
LOGGER.debug(REGISTRIES, "Frozen state restored.");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void revert(RegistryManager state, ResourceLocation registry, boolean lock)
{
LOGGER.debug(GD, "Reverting {} to {}", registry, state.getName());
LOGGER.debug(REGISTRIES, "Reverting {} to {}", registry, state.getName());
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(registry);
loadRegistry(registry, state, RegistryManager.ACTIVE, clazz, lock);
LOGGER.debug(GD, "Reverting complete");
LOGGER.debug(REGISTRIES, "Reverting complete");
}
//Lets us clear the map so we can rebuild it.
@@ -306,10 +308,12 @@ public class GameData
s.getAllowedValues().stream().map(Object::toString).collect(Collectors.joining( "," ))))
.collect(Collectors.joining(";"));
LOGGER.error("Registry replacements for vanilla block '{}' must not change the number or order of blockstates.\n"+
"\tOld: {}\n"+
"\tNew: {}", block.getRegistryName(), oldSequence, newSequence);
LOGGER.error(REGISTRIES,()-> new AdvancedLogMessageAdapter(sb-> {
sb.append("Registry replacements for vanilla block '").append(block.getRegistryName()).
append("' must not change the number or order of blockstates.\n");
sb.append("\tOld: ").append(oldSequence).append('\n');
sb.append("\tNew: ").append(newSequence);
}));
throw new RuntimeException("Invalid vanilla replacement. See log for details.");
}
}
@@ -557,7 +561,7 @@ public class GameData
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Multimap<ResourceLocation, ResourceLocation> injectSnapshot(Map<ResourceLocation, ForgeRegistry.Snapshot> snapshot, boolean injectFrozenData, boolean isLocalWorld)
{
LOGGER.info(GD, "Injecting existing registry data into this {} instance", EffectiveSide.get());
LOGGER.info(REGISTRIES, "Injecting existing registry data into this {} instance", EffectiveSide.get());
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.validateContent(name));
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.dump(name));
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.resetDelegates());
@@ -606,14 +610,14 @@ public class GameData
}
else if (isLocalWorld)
{
LOGGER.debug("Registry {}: Resuscitating dummy entry {}", key, dummy);
LOGGER.debug(REGISTRIES,"Registry {}: Resuscitating dummy entry {}", key, dummy);
}
else
{
// The server believes this is a dummy block identity, but we seem to have one locally. This is likely a conflict
// in mod setup - Mark this entry as a dummy
int id = reg.getID(dummy);
LOGGER.warn(GD, "Registry {}: The ID {} @ {} is currently locally mapped - it will be replaced with a dummy for this session", dummy, key, id);
LOGGER.warn(REGISTRIES, "Registry {}: The ID {} @ {} is currently locally mapped - it will be replaced with a dummy for this session", dummy, key, id);
reg.markDummy(dummy, id);
}
});
@@ -622,7 +626,7 @@ public class GameData
int count = missing.values().stream().mapToInt(Map::size).sum();
if (count > 0)
{
LOGGER.debug(GD,"There are {} mappings missing - attempting a mod remap", count);
LOGGER.debug(REGISTRIES,"There are {} mappings missing - attempting a mod remap", count);
Multimap<ResourceLocation, ResourceLocation> defaulted = ArrayListMultimap.create();
Multimap<ResourceLocation, ResourceLocation> failed = ArrayListMultimap.create();
@@ -636,8 +640,10 @@ public class GameData
List<MissingMappings.Mapping<?>> lst = event.getAllMappings().stream().filter(e -> e.getAction() == MissingMappings.Action.DEFAULT).sorted((a, b) -> a.toString().compareTo(b.toString())).collect(Collectors.toList());
if (!lst.isEmpty())
{
LOGGER.error(GD,"Unidentified mapping from registry {}", name);
lst.forEach(map -> LOGGER.error(" {}: {}", map.key, map.id));
LOGGER.error(REGISTRIES,()->new AdvancedLogMessageAdapter(sb->{
sb.append("Unidentified mapping from registry").append(name).append('\n');
lst.forEach(map->sb.append(" ").append(map.key).append(": ").append(map.id).append('\n'));
}));
}
event.getAllMappings().stream().filter(e -> e.getAction() == MissingMappings.Action.FAIL).forEach(fail -> failed.put(name, fail.key));
@@ -691,7 +697,7 @@ public class GameData
if (!defaulted.isEmpty())
{
if (isLocalWorld)
LOGGER.error(GD, "There are unidentified mappings in this world - we are going to attempt to process anyway");
LOGGER.error(REGISTRIES, "There are unidentified mappings in this world - we are going to attempt to process anyway");
}
}
@@ -811,9 +817,9 @@ public class GameData
if (i==keysSize-1) lifecycleEventProvider.changeProgression(LifecycleEventProvider.LifecycleEvent.Progression.NEXT);
eventDispatcher.accept(lifecycleEventProvider);
reg.freeze();
LOGGER.debug(CORE,"Applying holder lookups: {}", rl.toString());
LOGGER.debug(REGISTRIES,"Applying holder lookups: {}", rl.toString());
ObjectHolderRegistry.applyObjectHolders(rl::equals);
LOGGER.debug(CORE,"Holder lookups applied: {}", rl.toString());
LOGGER.debug(REGISTRIES,"Holder lookups applied: {}", rl.toString());
}
}
@@ -843,7 +849,7 @@ public class GameData
}
catch (NoSuchFieldException | SecurityException e)
{
LOGGER.error(GD, "Could not get `registryName` field from IForgeRegistryEntry.Impl", e);
LOGGER.error(REGISTRIES, "Could not get `registryName` field from IForgeRegistryEntry.Impl", e);
throw new RuntimeException(e);
}
}
@@ -853,7 +859,7 @@ public class GameData
}
catch (IllegalArgumentException | IllegalAccessException e)
{
LOGGER.error(GD,"Could not set `registryName` field in IForgeRegistryEntry.Impl to `{}`", name.toString(), e);
LOGGER.error(REGISTRIES,"Could not set `registryName` field in IForgeRegistryEntry.Impl to `{}`", name.toString(), e);
throw new RuntimeException(e);
}
@@ -46,6 +46,7 @@ import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;
import static net.minecraftforge.fml.Logging.CORE;
import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
/**
* Internal registry for tracking {@link ObjectHolder} references
@@ -89,7 +90,7 @@ public class ObjectHolderRegistry
public static void findObjectHolders()
{
LOGGER.debug(CORE,"Processing ObjectHolder annotations");
LOGGER.debug(REGISTRIES,"Processing ObjectHolder annotations");
final List<ModFileScanData.AnnotationData> annotations = ModList.get().getAllScanData().stream()
.map(ModFileScanData::getAnnotations)
.flatMap(Collection::stream)
@@ -108,7 +109,7 @@ public class ObjectHolderRegistry
annotations.stream().filter(a -> OBJECT_HOLDER.equals(a.getAnnotationType())).filter(a -> a.getTargetType() == ElementType.FIELD)
.forEach(data -> scanTarget(classModIds, classCache, data.getClassType(), data.getMemberName(), (String)data.getAnnotationData().get("value"), false, false));
LOGGER.info("Found {} ObjectHolder annotations", objectHolders.size());
LOGGER.debug(REGISTRIES,"Found {} ObjectHolder annotations", objectHolders.size());
}
private static void scanTarget(Map<Type, String> classModIds, Map<Type, Class<?>> classCache, Type type, @Nullable String annotationTarget, String value, boolean isClass, boolean extractFromValue)
@@ -142,7 +143,7 @@ public class ObjectHolderRegistry
String prefix = classModIds.get(type);
if (prefix == null)
{
LOGGER.warn("Found an unqualified ObjectHolder annotation ({}) without a modid context at {}.{}, ignoring", value, type, annotationTarget);
LOGGER.warn(REGISTRIES,"Found an unqualified ObjectHolder annotation ({}) without a modid context at {}.{}, ignoring", value, type, annotationTarget);
throw new IllegalStateException("Unqualified reference to ObjectHolder");
}
value = prefix + ':' + value;
@@ -178,9 +179,9 @@ public class ObjectHolderRegistry
public static void applyObjectHolders()
{
LOGGER.info("Applying holder lookups");
LOGGER.debug(REGISTRIES,"Applying holder lookups");
applyObjectHolders(key -> true);
LOGGER.info("Holder lookups applied");
LOGGER.debug(REGISTRIES,"Holder lookups applied");
}
public static void applyObjectHolders(Predicate<ResourceLocation> filter)