Clean up logging

This commit is contained in:
mezz committed 2017-06-24 01:46:05 -07:00
1 parent c0188d3228
commit 27321efb1f
9 files changed
+56 -55

No files matched your search

@@ -666,7 +666,7 @@ public class CraftingHelper {
}
catch (URISyntaxException e)
{
FMLLog.log(Level.ERROR, e, "Error finding Minecraft jar: " + e.toString());
FMLLog.log.error("Error finding Minecraft jar: ", e);
return false;
}
}
@@ -681,7 +681,7 @@ public class CraftingHelper {
}
catch (IOException e)
{
FMLLog.log(Level.ERROR, e, "Error loading FileSystem from jar: " + e.toString());
FMLLog.log.error("Error loading FileSystem from jar: ", e);
return false;
}
}
@@ -704,7 +704,7 @@ public class CraftingHelper {
}
catch (IOException e)
{
FMLLog.log(Level.ERROR, e, "Error loading _constants.json: " + e.toString());
FMLLog.log.error("Error loading _constants.json: ", e);
return false;
}
}
@@ -716,7 +716,7 @@ public class CraftingHelper {
}
catch (IOException e)
{
FMLLog.log(Level.ERROR, e, "Error iterating recipes for: " + ctx.getModId());
FMLLog.log.error("Error iterating recipes for: {}", ctx.getModId(), e);
return false;
}
@@ -742,12 +742,12 @@ public class CraftingHelper {
}
catch (JsonParseException e)
{
FMLLog.log(Level.ERROR, e, "Parsing error loading recipe " + key);
FMLLog.log.error("Parsing error loading recipe {}", key, e);
return false;
}
catch (IOException e)
{
FMLLog.log(Level.ERROR, e, "Couldn't read recipe " + key + " from " + f);
FMLLog.log.error("Couldn't read recipe {} from {}", key, f, e);
return false;
}
}
@@ -146,7 +146,7 @@ enum FMLHandshakeClientState implements IHandshakeState<FMLHandshakeClientState>
NetworkDispatcher dispatcher = ctx.channel().attr(NetworkDispatcher.FML_DISPATCHER).get();
dispatcher.rejectHandshake("Fatally missing blocks and items");
FMLLog.log.fatal("Failed to connect to server: there are {} missing blocks and items", locallyMissing.size());
locallyMissing.asMap().forEach((key, value) -> FMLLog.log.debug("Missing %s Entries: {}", key, value));
locallyMissing.asMap().forEach((key, value) -> FMLLog.log.debug("Missing {} Entries: {}", key, value));
return ERROR;
}
ctx.writeAndFlush(new FMLHandshakeMessage.HandshakeAck(ordinal())).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);
@@ -380,7 +380,7 @@ public class OreDictionary
matches = true;
if (oreName != null && !oreName.equals(ent.getValue()))
{
FMLLog.info("Invalid recipe found with multiple oredict ingredients in the same ingredient..."); //TODO: Write a dumper?
FMLLog.log.info("Invalid recipe found with multiple oredict ingredients in the same ingredient..."); //TODO: Write a dumper?
skip = true;
break;
}
@@ -259,7 +259,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
V oldEntry = getRaw(key);
if (oldEntry == value) // already registered, return prev registration's id
{
FMLLog.bigWarning("The object %s has been registered twice for the same name %s.", value, key);
FMLLog.bigWarning("The object {} has been registered twice for the same name {}.", value, key);
return this.getID(value);
}
if (oldEntry != null) // duplicate name
@@ -310,10 +310,10 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
this.add.onAdd(this, this.stage, idToUse, value);
if (this.dummies.remove(key) && DEBUG)
FMLLog.fine("Registry Dummy Remove: %s", key);
FMLLog.log.debug("Registry Dummy Remove: {}", key);
if (DEBUG)
FMLLog.finer("Registry add: %s %d %s (req. id %d)", key, idToUse, value, id);
FMLLog.log.trace("Registry add: {} {} {} (req. id {})", key, idToUse, value, id);
return idToUse;
}
@@ -342,7 +342,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
throw new IllegalStateException(String.format("Attempted to register the alias %s -> %s to late", from, to));
this.aliases.put(from, to);
if (DEBUG)
FMLLog.finer("Registry alias: %s -> %s", from, to);
FMLLog.log.trace("Registry alias: {} -> {}", from, to);
}
void addDummy(ResourceLocation key)
@@ -351,7 +351,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
throw new IllegalStateException(String.format("Attempted to register the dummy %s to late", key));
this.dummies.add(key);
if (DEBUG)
FMLLog.finer("Registry dummy: %s -> %s", key);
FMLLog.log.trace("Registry dummy: {}", key);
}
private RegistryDelegate<V> getDelegate(V thing)
@@ -465,7 +465,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
int realId = add(id, entry.getValue());
if (id != realId && id != -1)
{
FMLLog.warning("Registered object did not get ID it asked for. Name: %s Type: %s Expected: %s Got: %s", entry.getKey(), this.getRegistrySuperType().getName(), id, realId);
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", entry.getKey(), this.getRegistrySuperType().getName(), id, realId);
errored = true;
}
}
@@ -477,14 +477,14 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
OverrideOwner owner = from.override_owners.inverse().get(value);
if (owner == null)
{
FMLLog.warning("Registered override did not have an associated owner object. Name: %s Type: %s Value: %s", entry.getKey(), this.getRegistrySuperType().getName(), value);
FMLLog.log.warn("Registered override did not have an associated owner object. Name: {} Type: {} Value: {}", entry.getKey(), this.getRegistrySuperType().getName(), value);
errored = true;
continue;
}
int realId = add(id, value, owner.owner);
if (id != realId && id != -1)
{
FMLLog.warning("Registered object did not get ID it asked for. Name: %s Type: %s Expected: %s Got: %s", entry.getKey(), this.getRegistrySuperType().getName(), id, realId);
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", entry.getKey(), this.getRegistrySuperType().getName(), id, realId);
errored = true;
}
}
@@ -580,8 +580,8 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
Collections.sort(ids);
FMLLog.finer("Registry Name : %s", name);
ids.forEach(id -> FMLLog.finer("Registry: %d %s %s", id, getKey(getValue(id)), getValue(id)));
FMLLog.log.trace("Registry Name : {}", name);
ids.forEach(id -> FMLLog.log.trace("Registry: {} {} {}", id, getKey(getValue(id)), getValue(id)));
}
public void loadIds(Map<ResourceLocation, Integer> ids, Map<ResourceLocation, String> overrides, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remapped, ForgeRegistry<V> old, ResourceLocation name)
@@ -594,13 +594,13 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
if (currId == -1)
{
FMLLog.info("Found a missing id from the world %s", itemName);
FMLLog.log.info("Found a missing id from the world {}", itemName);
missing.put(itemName, newId);
continue; // no block/item -> nothing to add
}
else if (currId != newId)
{
FMLLog.fine("Fixed %s id mismatch %s: %d (init) -> %d (map).", name, itemName, currId, newId);
FMLLog.log.debug("Fixed {} id mismatch {}: {} (init) -> {} (map).", name, itemName, currId, newId);
remapped.put(itemName, new Integer[] {currId, newId});
}
V obj = old.getRaw(itemName);
@@ -620,7 +620,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
OverrideOwner owner = old.override_owners.inverse().get(value);
if (owner == null)
{
FMLLog.warning("Registered override did not have an associated owner object. Name: %s Type: %s Value: %s", entry.getKey(), this.getRegistrySuperType().getName(), value);
FMLLog.log.warn("Registered override did not have an associated owner object. Name: {} Type: {} Value: {}", entry.getKey(), this.getRegistrySuperType().getName(), value);
continue;
}
@@ -629,12 +629,12 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
int realId = add(newId, value, owner.owner);
if (newId != realId)
FMLLog.warning("Registered object did not get ID it asked for. Name: %s Type: %s Expected: %s Got: %s", entry.getKey(), this.getRegistrySuperType().getName(), newId, realId);
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", entry.getKey(), this.getRegistrySuperType().getName(), newId, realId);
}
int realId = add(newId, obj, primaryName == null ? itemName.getResourceDomain() : primaryName);
if (realId != newId)
FMLLog.warning("Registered object did not get ID it asked for. Name: %s Type: %s Expected: %s Got: %s", entry.getKey(), this.getRegistrySuperType().getName(), newId, realId);
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", entry.getKey(), this.getRegistrySuperType().getName(), newId, realId);
}
}
@@ -645,14 +645,14 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
V dummy = this.dummyFactory.createDummy(key);
if (DEBUG)
FMLLog.finer("Registry Dummy Add: %s %d -> %s", key, id, dummy);
FMLLog.log.trace("Registry Dummy Add: {} {} -> {}", key, id, dummy);
//It was blocked before so we need to unset the blocking map
this.availabilityMap.clear(id);
int realId = this.add(id, dummy);
if (realId != id)
FMLLog.warning("Registered object did not get ID it asked for. Name: %s Type: %s Expected: %s Got: %s", key, dummy.getRegistryType().getName(), id, realId);
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, dummy.getRegistryType().getName(), id, realId);
this.dummies.add(key);
return true;
@@ -699,7 +699,7 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
void processMissingEvent(ResourceLocation name, ForgeRegistry<V> pool, List<MissingMappings.Mapping<V>> mappings, Map<ResourceLocation, Integer> missing, Map<ResourceLocation, Integer[]> remaps, Collection<ResourceLocation> defaulted, Collection<ResourceLocation> failed)
{
FMLLog.fine("Processing missing event for %s:", name);
FMLLog.log.debug("Processing missing event for {}:", name);
int ignored = 0;
for (MissingMappings.Mapping<V> remap : mappings)
@@ -711,19 +711,19 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
// entry re-mapped, finish the registration with the new name/object, but the old id
int currId = getID(remap.getTarget());
ResourceLocation newName = pool.getKey(remap.getTarget());
FMLLog.fine(" Remapping %s -> %s.", remap.key, newName);
FMLLog.log.debug(" Remapping {} -> {}.", remap.key, newName);
missing.remove(remap.key);
//I don't think this will work, but I dont think it ever worked.. the item is already in the map with a different id... we want to fix that..
int realId = this.add(remap.id, remap.getTarget());
if (realId != remap.id)
FMLLog.warning("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", newName, this.getRegistrySuperType(), remap.id, realId);
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", newName, this.getRegistrySuperType(), remap.id, realId);
this.addAlias(remap.key, newName);
if (currId != realId)
{
FMLLog.info(" Fixed id mismatch %s: %d (init) -> %d (map).", newName, currId, realId);
FMLLog.log.info(" Fixed id mismatch {}: {} (init) -> {} (map).", newName, currId, realId);
remaps.put(newName, new Integer[] {currId, realId});
}
}
@@ -736,24 +736,24 @@ public class ForgeRegistry<V extends IForgeRegistryEntry<V>> implements IForgeRe
}
else if (action == MissingMappings.Action.IGNORE)
{
FMLLog.fine(" Ignoring %s", remap.key);
FMLLog.log.debug(" Ignoring {}", remap.key);
ignored++;
}
else if (action == MissingMappings.Action.FAIL)
{
FMLLog.fine(" Failing %s!", remap.key);
FMLLog.log.debug(" Failing {}!", remap.key);
failed.add(remap.key);
}
else if (action == MissingMappings.Action.WARN)
{
FMLLog.warning(" %s may cause world breakage!", remap.key);
FMLLog.log.warn(" {} may cause world breakage!", remap.key);
}
this.block(remap.id);
}
}
if (failed.isEmpty() && ignored > 0)
FMLLog.fine("There were %d missing mappings that have been ignored", ignored);
FMLLog.log.debug("There were {} missing mappings that have been ignored", ignored);
}
private static class OverrideOwner
@@ -112,7 +112,7 @@ public class GameData
{
if ( DISABLE_VANILLA_REGISTRIES)
{
FMLLog.bigWarning("DISABELING VANILLA REGISTRY CREATION AS PER SYSTEM VARIABLE SETTING! forge.disableVanillaGameData");
FMLLog.bigWarning("DISABLING VANILLA REGISTRY CREATION AS PER SYSTEM VARIABLE SETTING! forge.disableVanillaGameData");
return;
}
if (hasInit)
@@ -188,7 +188,7 @@ public class GameData
@SuppressWarnings({ "unchecked", "rawtypes" })
public static void vanillaSnapshot()
{
FMLLog.fine("Creating vanilla freeze snapshot");
FMLLog.log.debug("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());
@@ -201,13 +201,13 @@ public class GameData
});
RegistryManager.VANILLA.registries.forEach(LOCK_VANILLA);
RegistryManager.ACTIVE.registries.forEach(LOCK_VANILLA);
FMLLog.fine("Vanilla freeze snapshot created");
FMLLog.log.debug("Vanilla freeze snapshot created");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void freezeData()
{
FMLLog.fine("Freezing registries");
FMLLog.log.debug("Freezing registries");
for (Map.Entry<ResourceLocation, ForgeRegistry<? extends IForgeRegistryEntry<?>>> r : RegistryManager.ACTIVE.registries.entrySet())
{
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(r.getKey());
@@ -219,7 +219,7 @@ public class GameData
reg.freeze();
});
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.freeze());
FMLLog.fine("All registries frozen");
FMLLog.log.debug("All registries frozen");
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@@ -227,12 +227,12 @@ public class GameData
{
if (RegistryManager.FROZEN.registries.isEmpty())
{
FMLLog.warning("Can't revert to frozen GameData state without freezing first.");
FMLLog.log.warn("Can't revert to frozen GameData state without freezing first.");
return;
}
RegistryManager.ACTIVE.registries.forEach((name, reg) -> reg.resetDelegates());
FMLLog.fine("Reverting to frozen data state.");
FMLLog.log.debug("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());
@@ -243,16 +243,16 @@ public class GameData
// the id mapping has reverted, ensure we sync up the object holders
ObjectHolderRegistry.INSTANCE.applyObjectHolders();
FMLLog.fine("Frozen state restored.");
FMLLog.log.debug("Frozen state restored.");
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void revert(RegistryManager state, ResourceLocation registry, boolean lock)
{
FMLLog.fine("Reverting {} to {}", registry, state.getName());
FMLLog.log.debug("Reverting {} to {}", registry, state.getName());
final Class<? extends IForgeRegistryEntry> clazz = RegistryManager.ACTIVE.getSuperType(registry);
loadRegistry(registry, RegistryManager.FROZEN, RegistryManager.ACTIVE, clazz, lock);
FMLLog.fine("Reverting complete");
FMLLog.log.debug("Reverting complete");
}
//Lets us clear the map so we can rebuild it.
@@ -431,7 +431,7 @@ public class GameData
@SuppressWarnings({ "unchecked", "rawtypes" })
public static Multimap<ResourceLocation, ResourceLocation> injectSnapshot(Map<ResourceLocation, ForgeRegistry.Snapshot> snapshot, boolean injectFrozenData, boolean isLocalWorld)
{
FMLLog.info("Injecting existing registry data into this %s instance", FMLCommonHandler.instance().getEffectiveSide().isServer() ? "server" : "client");
FMLLog.log.info("Injecting existing registry data into this {} instance", FMLCommonHandler.instance().getEffectiveSide().isServer() ? "server" : "client");
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());
@@ -481,14 +481,14 @@ public class GameData
else if (isLocalWorld)
{
if (ForgeRegistry.DEBUG)
FMLLog.log(Level.DEBUG, "Registry %s: Resuscitating dummy entry %s", e.getKey(), dummy);
FMLLog.log.debug("Registry {}: Resuscitating dummy entry {}", e.getKey(), 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);
FMLLog.log(Level.WARN, "Registry $s: The ID %d is currently locally mapped - it will be replaced with a dummy for this session", e.getKey(), id);
FMLLog.log.warn("Registry {}: The ID {} is currently locally mapped - it will be replaced with a dummy for this session", e.getKey(), id);
reg.markDummy(dummy, id);
}
});
@@ -497,7 +497,7 @@ public class GameData
int count = missing.values().stream().mapToInt(e -> e.size()).sum();
if (count > 0)
{
FMLLog.fine("There are %d mappings missing - attempting a mod remap", count);
FMLLog.log.debug("There are {} mappings missing - attempting a mod remap", count);
Multimap<ResourceLocation, ResourceLocation> defaulted = ArrayListMultimap.create();
Multimap<ResourceLocation, ResourceLocation> failed = ArrayListMultimap.create();
@@ -511,9 +511,9 @@ public class GameData
List<MissingMappings.Mapping<?>> lst = event.getAllMappings().stream().filter(e -> e.getAction() == MissingMappings.Action.DEFAULT).collect(Collectors.toList());
if (!lst.isEmpty())
{
FMLLog.severe("Unidentified mapping from registry %s", name);
FMLLog.log.error("Unidentified mapping from registry {}", name);
lst.forEach(map -> {
FMLLog.severe(" %s: %d", map.key, map.id);
FMLLog.log.error(" {}: {}", map.key, map.id);
if (!isLocalWorld)
defaulted.put(name, map.key);
});
@@ -555,7 +555,7 @@ public class GameData
else
{
for (int x = 0; x < 10; x++)
FMLLog.severe("!!!!!!!!!! UPDATING WORLD WITHOUT DOING BACKUP !!!!!!!!!!!!!!!!");
FMLLog.log.error("!!!!!!!!!! UPDATING WORLD WITHOUT DOING BACKUP !!!!!!!!!!!!!!!!");
}
}
catch (IOException e)
@@ -568,7 +568,7 @@ public class GameData
if (!defaulted.isEmpty())
{
if (isLocalWorld)
FMLLog.severe("There are unidentified mappings in this world - we are going to attempt to process anyway");
FMLLog.log.error("There are unidentified mappings in this world - we are going to attempt to process anyway");
}
}
@@ -39,7 +39,7 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
int realId = this.delegate.add(id, value);
if (realId != id && id != -1)
FMLLog.warning("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
}
@Override
@@ -48,6 +48,7 @@ class NamespacedDefaultedWrapper<V extends IForgeRegistryEntry<V>> extends Regis
register(-1, key, value);
}
@Override
public void validateKey()
{
this.delegate.validateKey();
@@ -37,7 +37,7 @@ class NamespacedWrapper<V extends IForgeRegistryEntry<V>> extends RegistryNamesp
int realId = this.delegate.add(id, value);
if (realId != id && id != -1)
FMLLog.warning("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
FMLLog.log.warn("Registered object did not get ID it asked for. Name: {} Type: {} Expected: {} Got: {}", key, value.getRegistryType().getName(), id, realId);
}
@Override
@@ -84,7 +84,7 @@ public class RegistryManager
if (!overlappedTypes.isEmpty())
{
Class<?> foundType = overlappedTypes.iterator().next();
FMLLog.severe("Found existing registry of type %s named %s, you cannot create a new registry (%s) with type %s, as %s has a parent of that type", foundType, superTypes.get(foundType), name, type, type);
FMLLog.log.error("Found existing registry of type {} named {}, you cannot create a new registry ({}) with type {}, as {} has a parent of that type", foundType, superTypes.get(foundType), name, type, type);
throw new IllegalArgumentException("Duplicate registry parent type found - you can only have one registry for a particular super type");
}
ForgeRegistry<V> reg = new ForgeRegistry<V>(type, defaultKey, min, max, create, add, clear, this, allowOverrides, isModifiable, dummyFactory);