From a0fcbdccb54f8f991d37f9c601e3e118465b6e02 Mon Sep 17 00:00:00 2001 From: Christian Date: Mon, 16 Dec 2013 11:47:48 -0500 Subject: [PATCH] Update for log4j2 --- .../net/minecraft/client/Minecraft.java.patch | 22 +- .../minecraft/entity/EntityList.java.patch | 16 +- .../tileentity/TileEntity.java.patch | 20 +- .../chunk/storage/AnvilChunkLoader.java.patch | 18 +- .../cpw/mods/fml/client/FMLClientHandler.java | 12 +- .../mods/fml/client/FMLFileResourcePack.java | 4 +- .../fml/client/FMLFolderResourcePack.java | 4 +- .../java/cpw/mods/fml/client/GuiModList.java | 17 ++ .../cpw/mods/fml/common/FMLCommonHandler.java | 6 +- .../cpw/mods/fml/common/FMLContainer.java | 4 +- .../main/java/cpw/mods/fml/common/FMLLog.java | 29 +-- .../cpw/mods/fml/common/FMLModContainer.java | 32 +-- .../cpw/mods/fml/common/ILanguageAdapter.java | 6 +- .../cpw/mods/fml/common/LoadController.java | 27 +-- .../main/java/cpw/mods/fml/common/Loader.java | 33 +-- .../mods/fml/common/MetadataCollection.java | 4 +- .../main/java/cpw/mods/fml/common/Mod.java | 9 + .../cpw/mods/fml/common/ModAPIManager.java | 2 +- .../cpw/mods/fml/common/ModClassLoader.java | 4 +- .../common/ObfuscationReflectionHelper.java | 14 +- .../cpw/mods/fml/common/ProxyInjector.java | 4 +- .../mods/fml/common/asm/FMLSanityChecker.java | 4 +- .../asm/transformers/AccessTransformer.java | 2 +- .../asm/transformers/ModAPITransformer.java | 24 +- .../deobf/FMLDeobfuscatingRemapper.java | 14 +- .../common/discovery/DirectoryDiscoverer.java | 7 +- .../fml/common/discovery/JarDiscoverer.java | 8 +- .../fml/common/discovery/ModDiscoverer.java | 4 +- .../common/discovery/asm/ASMModParser.java | 4 +- .../fml/common/event/FMLInterModComms.java | 2 +- .../event/FMLPreInitializationEvent.java | 10 +- .../fml/common/launcher/FMLDeobfTweaker.java | 7 +- .../mods/fml/common/launcher/FMLTweaker.java | 8 +- .../fml/common/network/NetworkRegistry.java | 4 +- .../network/internal/EntitySpawnHandler.java | 4 +- .../network/internal/NetworkModHolder.java | 12 +- .../fml/common/patcher/ClassPatchManager.java | 15 +- .../mods/fml/common/patcher/GenDiffSet.java | 6 +- .../fml/common/registry/EntityRegistry.java | 9 +- .../mods/fml/common/registry/GameData.java | 4 +- .../fml/common/registry/GameRegistry.java | 4 +- .../fml/common/registry/LanguageRegistry.java | 8 +- .../fml/common/versioning/VersionParser.java | 4 +- .../mods/fml/relauncher/CoreModManager.java | 47 ++-- .../mods/fml/relauncher/FMLCorePlugin.java | 6 + .../mods/fml/relauncher/FMLInjectionData.java | 4 +- .../mods/fml/relauncher/FMLLaunchHandler.java | 4 +- .../mods/fml/relauncher/FMLLogFormatter.java | 73 ------ .../mods/fml/relauncher/FMLRelaunchLog.java | 221 ++---------------- .../fml/relauncher/IFMLLoadingPlugin.java | 6 + .../minecraft/src/FMLRenderAccessLibrary.java | 8 +- 51 files changed, 305 insertions(+), 515 deletions(-) delete mode 100644 fml/src/main/java/cpw/mods/fml/relauncher/FMLLogFormatter.java diff --git a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch index dd4c8406d..9f5515c5e 100644 --- a/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/fml/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -19,16 +19,24 @@ @SideOnly(Side.CLIENT) public class Minecraft implements IPlayerUsage { -@@ -457,6 +462,8 @@ +@@ -448,7 +453,7 @@ + this.field_110451_am = new SimpleReloadableResourceManager(this.field_110452_an); + this.field_135017_as = new LanguageManager(this.field_110452_an, this.field_71474_y.field_74363_ab); + this.field_110451_am.func_110542_a(this.field_135017_as); +- this.func_110436_a(); ++ FMLClientHandler.instance().beginMinecraftLoading(this, this.field_110449_ao, this.field_110451_am); + this.field_71446_o = new TextureManager(this.field_110451_am); + this.field_110451_am.func_110542_a(this.field_71446_o); + this.field_147127_av = new SoundHandler(this.field_110451_am, this.field_71474_y); +@@ -457,6 +462,7 @@ this.func_71357_I(); this.field_71466_p = new FontRenderer(this.field_71474_y, new ResourceLocation("textures/font/ascii.png"), this.field_71446_o, false); -+ FMLClientHandler.instance().beginMinecraftLoading(this, this.field_110449_ao, this.field_110451_am); + if (this.field_71474_y.field_74363_ab != null) { this.field_71466_p.func_78264_a(this.field_135017_as.func_135042_a() || this.field_71474_y.field_151455_aw); -@@ -508,6 +515,7 @@ +@@ -508,6 +514,7 @@ this.field_71446_o.func_130088_a(TextureMap.field_110576_c, new TextureMap(1, "textures/items")); GL11.glViewport(0, 0, this.field_71443_c, this.field_71440_d); this.field_71452_i = new EffectRenderer(this.field_71441_e, this.field_71446_o); @@ -36,7 +44,7 @@ this.func_71361_d("Post startup"); this.field_71456_v = new GuiIngame(this); -@@ -527,6 +535,7 @@ +@@ -527,6 +534,7 @@ this.func_71352_k(); } @@ -44,7 +52,7 @@ Display.setVSyncEnabled(this.field_71474_y.field_74352_v); } -@@ -916,9 +925,11 @@ +@@ -915,9 +923,11 @@ if (!this.field_71454_w) { @@ -56,7 +64,7 @@ } GL11.glFlush(); -@@ -1491,11 +1502,15 @@ +@@ -1490,11 +1500,15 @@ public void func_71407_l() { @@ -72,7 +80,7 @@ this.field_71424_I.func_76320_a("gui"); if (!this.field_71445_n) -@@ -1978,6 +1993,8 @@ +@@ -1977,6 +1991,8 @@ this.field_71453_ak.func_74428_b(); } diff --git a/fml/patches/minecraft/net/minecraft/entity/EntityList.java.patch b/fml/patches/minecraft/net/minecraft/entity/EntityList.java.patch index 540cf900b..5395ce369 100644 --- a/fml/patches/minecraft/net/minecraft/entity/EntityList.java.patch +++ b/fml/patches/minecraft/net/minecraft/entity/EntityList.java.patch @@ -1,15 +1,19 @@ --- ../src-base/minecraft/net/minecraft/entity/EntityList.java +++ ../src-work/minecraft/net/minecraft/entity/EntityList.java -@@ -5,6 +5,8 @@ +@@ -5,6 +5,7 @@ import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; -+import java.util.logging.Level; + import net.minecraft.entity.ai.EntityMinecartMobSpawner; import net.minecraft.entity.boss.EntityDragon; import net.minecraft.entity.boss.EntityWither; -@@ -66,6 +68,8 @@ +@@ -63,9 +64,13 @@ + import net.minecraft.stats.StatBase; + import net.minecraft.stats.StatList; + import net.minecraft.world.World; ++ ++import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -18,7 +22,7 @@ public class EntityList { private static final Logger field_151516_b = LogManager.getLogger(); -@@ -145,9 +149,10 @@ +@@ -145,9 +150,10 @@ p_75615_0_.func_82580_o("Type"); } @@ -30,7 +34,7 @@ if (oclass != null) { -@@ -161,7 +166,17 @@ +@@ -161,7 +167,17 @@ if (entity != null) { @@ -41,7 +45,7 @@ + } + catch (Exception e) + { -+ FMLLog.log(Level.SEVERE, e, ++ FMLLog.log(Level.ERROR, e, + "An Entity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", + p_75615_0_.func_74779_i("id"), oclass.getName()); + entity = null; diff --git a/fml/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch b/fml/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch index b19e43185..7b3b32225 100644 --- a/fml/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch +++ b/fml/patches/minecraft/net/minecraft/tileentity/TileEntity.java.patch @@ -1,6 +1,6 @@ --- ../src-base/minecraft/net/minecraft/tileentity/TileEntity.java +++ ../src-work/minecraft/net/minecraft/tileentity/TileEntity.java -@@ -1,10 +1,13 @@ +@@ -1,10 +1,12 @@ package net.minecraft.tileentity; +import cpw.mods.fml.common.FMLLog; @@ -9,12 +9,20 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.Callable; -+import java.util.logging.Level; + import net.minecraft.block.Block; import net.minecraft.block.BlockJukebox; import net.minecraft.crash.CrashReportCategory; -@@ -87,9 +90,10 @@ +@@ -12,6 +14,8 @@ + import net.minecraft.nbt.NBTTagCompound; + import net.minecraft.network.Packet; + import net.minecraft.world.World; ++ ++import org.apache.logging.log4j.Level; + import org.apache.logging.log4j.LogManager; + import org.apache.logging.log4j.Logger; + +@@ -87,9 +91,10 @@ { TileEntity tileentity = null; @@ -26,7 +34,7 @@ if (oclass != null) { -@@ -103,7 +107,17 @@ +@@ -103,7 +108,17 @@ if (tileentity != null) { @@ -36,7 +44,7 @@ + } + catch (Exception ex) + { -+ FMLLog.log(Level.SEVERE, ex, ++ FMLLog.log(Level.ERROR, ex, + "A TileEntity %s(%s) has thrown an exception during loading, its state cannot be restored. Report this to the mod author", + p_145827_0_.func_74779_i("id"), oclass.getName()); + tileentity = null; @@ -44,7 +52,7 @@ } else { -@@ -137,7 +151,6 @@ +@@ -137,7 +152,6 @@ } } diff --git a/fml/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch b/fml/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch index afdbf1d7b..3f471a2d2 100644 --- a/fml/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch +++ b/fml/patches/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java.patch @@ -1,15 +1,19 @@ --- ../src-base/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java +++ ../src-work/minecraft/net/minecraft/world/chunk/storage/AnvilChunkLoader.java -@@ -9,6 +9,8 @@ +@@ -9,6 +9,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -+import java.util.logging.Level; + import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; -@@ -27,6 +29,8 @@ +@@ -24,9 +25,13 @@ + import net.minecraft.world.chunk.NibbleArray; + import net.minecraft.world.storage.IThreadedFileIO; + import net.minecraft.world.storage.ThreadedFileIOBase; ++ ++import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -18,7 +22,7 @@ public class AnvilChunkLoader implements IChunkLoader, IThreadedFileIO { private static final Logger field_151505_a = LogManager.getLogger(); -@@ -260,11 +264,20 @@ +@@ -260,11 +265,20 @@ Entity entity = (Entity)iterator.next(); nbttagcompound1 = new NBTTagCompound(); @@ -35,14 +39,14 @@ } + catch (Exception e) + { -+ FMLLog.log(Level.SEVERE, e, ++ FMLLog.log(Level.ERROR, e, + "An Entity type %s has thrown an exception trying to write state. It will not persist. Report this to the mod author", + entity.getClass().getName()); + } } } -@@ -276,8 +289,16 @@ +@@ -276,8 +290,16 @@ { TileEntity tileentity = (TileEntity)iterator.next(); nbttagcompound1 = new NBTTagCompound(); @@ -52,7 +56,7 @@ + } + catch (Exception e) + { -+ FMLLog.log(Level.SEVERE, e, ++ FMLLog.log(Level.ERROR, e, + "A TileEntity type %s has throw an exception trying to write state. It will not persist. Report this to the mod author", + tileentity.getClass().getName()); + } diff --git a/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java b/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java index fb19b35bc..b44537b4f 100644 --- a/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/src/main/java/cpw/mods/fml/client/FMLClientHandler.java @@ -17,7 +17,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import java.util.logging.Logger; import net.minecraft.client.Minecraft; @@ -176,7 +176,7 @@ public class FMLClientHandler implements IFMLSidedHandler } catch (CustomModLoadingErrorDisplayException custom) { - FMLLog.log(Level.SEVERE, custom, "A custom exception was thrown by a mod, the game will now halt"); + FMLLog.log(Level.ERROR, custom, "A custom exception was thrown by a mod, the game will now halt"); customError = custom; } catch (LoaderException le) @@ -226,7 +226,7 @@ public class FMLClientHandler implements IFMLSidedHandler } catch (CustomModLoadingErrorDisplayException custom) { - FMLLog.log(Level.SEVERE, custom, "A custom exception was thrown by a mod, the game will now halt"); + FMLLog.log(Level.ERROR, custom, "A custom exception was thrown by a mod, the game will now halt"); customError = custom; return; } @@ -237,7 +237,7 @@ public class FMLClientHandler implements IFMLSidedHandler } // Reload resources - client.func_110436_a(); +// client.func_110436_a(); RenderingRegistry.instance().loadEntityRenderers((Map, Render>)RenderManager.field_78727_a.field_78729_o); loading = false; KeyBindingRegistry.instance().uploadKeyBindingsToGame(client.field_71474_y); @@ -445,12 +445,12 @@ public class FMLClientHandler implements IFMLSidedHandler } catch (NoSuchMethodException e) { - FMLLog.log(Level.SEVERE, "The container %s (type %s) returned an invalid class for it's resource pack.", container.getName(), container.getClass().getName()); + FMLLog.log(Level.ERROR, "The container %s (type %s) returned an invalid class for it's resource pack.", container.getName(), container.getClass().getName()); return; } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "An unexpected exception occurred constructing the custom resource pack for %s", container.getName()); + FMLLog.log(Level.ERROR, e, "An unexpected exception occurred constructing the custom resource pack for %s", container.getName()); throw Throwables.propagate(e); } } diff --git a/fml/src/main/java/cpw/mods/fml/client/FMLFileResourcePack.java b/fml/src/main/java/cpw/mods/fml/client/FMLFileResourcePack.java index aaca5c248..a28de4249 100644 --- a/fml/src/main/java/cpw/mods/fml/client/FMLFileResourcePack.java +++ b/fml/src/main/java/cpw/mods/fml/client/FMLFileResourcePack.java @@ -4,7 +4,7 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import javax.imageio.ImageIO; @@ -41,7 +41,7 @@ public class FMLFileResourcePack extends FileResourcePack { { if ("pack.mcmeta".equals(resourceName)) { - FMLLog.log(container.getName(), Level.WARNING, "Mod %s is missing a pack.mcmeta file, things may not work well", container.getName()); + FMLLog.log(container.getName(), Level.DEBUG, "Mod %s is missing a pack.mcmeta file, substituting a dummy one", container.getName()); return new ByteArrayInputStream(("{\n" + " \"pack\": {\n"+ " \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+ diff --git a/fml/src/main/java/cpw/mods/fml/client/FMLFolderResourcePack.java b/fml/src/main/java/cpw/mods/fml/client/FMLFolderResourcePack.java index 6fed90810..b82417b9a 100644 --- a/fml/src/main/java/cpw/mods/fml/client/FMLFolderResourcePack.java +++ b/fml/src/main/java/cpw/mods/fml/client/FMLFolderResourcePack.java @@ -4,7 +4,7 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import javax.imageio.ImageIO; @@ -46,7 +46,7 @@ public class FMLFolderResourcePack extends FolderResourcePack { { if ("pack.mcmeta".equals(resourceName)) { - FMLLog.log(container.getName(), Level.WARNING, "Mod %s is missing a pack.mcmeta file, things may not work well", container.getName()); + FMLLog.log(container.getName(), Level.DEBUG, "Mod %s is missing a pack.mcmeta file, substituting a dummy one", container.getName()); return new ByteArrayInputStream(("{\n" + " \"pack\": {\n"+ " \"description\": \"dummy FML pack for "+container.getName()+"\",\n"+ diff --git a/fml/src/main/java/cpw/mods/fml/client/GuiModList.java b/fml/src/main/java/cpw/mods/fml/client/GuiModList.java index 313dc764b..5ef0f3aef 100644 --- a/fml/src/main/java/cpw/mods/fml/client/GuiModList.java +++ b/fml/src/main/java/cpw/mods/fml/client/GuiModList.java @@ -52,6 +52,8 @@ public class GuiModList extends GuiScreen private ModContainer selectedMod; private int listWidth; private ArrayList mods; + private GuiButton configModButton; + private GuiButton disableModButton; /** * @param mainMenu @@ -90,6 +92,10 @@ public class GuiModList extends GuiScreen } listWidth=Math.min(listWidth, 150); this.field_146292_n.add(new GuiButton(6, this.field_146294_l / 2 - 75, this.field_146295_m - 38, I18n.func_135052_a("gui.done"))); + configModButton = new GuiButton(7, 10, this.field_146295_m - 58, this.listWidth, 18, "Config"); + disableModButton = new GuiButton(8, 10, this.field_146295_m - 36, this.listWidth, 18, "Disable"); + this.field_146292_n.add(configModButton); + this.field_146292_n.add(disableModButton); this.modList=new GuiSlotModList(this, mods, listWidth); this.modList.registerScrollButtons(this.field_146292_n, 7, 8); } @@ -123,6 +129,10 @@ public class GuiModList extends GuiScreen if (selectedMod != null) { GL11.glEnable(GL11.GL_BLEND); if (!selectedMod.getMetadata().autogenerated) { + configModButton.field_146125_m = true; + disableModButton.field_146125_m = true; + disableModButton.packedFGColour = 0xFF3377; + configModButton.field_146124_l = false; int shifty = 35; String logoFile = selectedMod.getMetadata().logoFile; if (!logoFile.isEmpty()) @@ -199,9 +209,16 @@ public class GuiModList extends GuiScreen this.func_73732_a(this.field_146289_q, String.format("Mod State: %s",Loader.instance().getModState(selectedMod)), offset, 55, 0xFFFFFF); this.func_73732_a(this.field_146289_q, "No mod information found", offset, 65, 0xDDDDDD); this.func_73732_a(this.field_146289_q, "Ask your mod author to provide a mod mcmod.info file", offset, 75, 0xDDDDDD); + configModButton.field_146125_m = false; + disableModButton.field_146125_m = false; } GL11.glDisable(GL11.GL_BLEND); } + else + { + configModButton.field_146125_m = false; + disableModButton.field_146125_m = false; + } super.func_73863_a(p_571_1_, p_571_2_, p_571_3_); } diff --git a/fml/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java b/fml/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java index 9701c409a..e0bccf39a 100644 --- a/fml/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/FMLCommonHandler.java @@ -16,8 +16,8 @@ import java.util.EnumSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Logger; import net.minecraft.crash.CrashReport; import net.minecraft.crash.CrashReportCategory; @@ -181,7 +181,7 @@ public class FMLCommonHandler */ public void raiseException(Throwable exception, String message, boolean stopGame) { - FMLLog.log(Level.SEVERE, exception, "Something raised an exception. The message was '%s'. 'stopGame' is %b", message, stopGame); + FMLLog.log(Level.ERROR, exception, "Something raised an exception. The message was '%s'. 'stopGame' is %b", message, stopGame); if (stopGame) { getSidedDelegate().haltGame(message,exception); diff --git a/fml/src/main/java/cpw/mods/fml/common/FMLContainer.java b/fml/src/main/java/cpw/mods/fml/common/FMLContainer.java index 0ecc0ce23..448b0defe 100644 --- a/fml/src/main/java/cpw/mods/fml/common/FMLContainer.java +++ b/fml/src/main/java/cpw/mods/fml/common/FMLContainer.java @@ -17,7 +17,7 @@ import java.security.cert.Certificate; import java.util.Arrays; import java.util.Map; import java.util.Map.Entry; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -122,7 +122,7 @@ public class FMLContainer extends DummyModContainer implements WorldAccessContai ModContainer container = Loader.instance().getIndexedModList().get(modId); if (container == null) { - FMLLog.log("fml.ModTracker", Level.SEVERE, "This world was saved with mod %s which appears to be missing, things may not work well", modId); + FMLLog.log("fml.ModTracker", Level.ERROR, "This world was saved with mod %s which appears to be missing, things may not work well", modId); continue; } if (!modVersion.equals(container.getVersion())) diff --git a/fml/src/main/java/cpw/mods/fml/common/FMLLog.java b/fml/src/main/java/cpw/mods/fml/common/FMLLog.java index 4c8e64c37..19cd725ae 100644 --- a/fml/src/main/java/cpw/mods/fml/common/FMLLog.java +++ b/fml/src/main/java/cpw/mods/fml/common/FMLLog.java @@ -12,17 +12,17 @@ package cpw.mods.fml.common; -import java.util.logging.Level; -import java.util.logging.Logger; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Logger; @SuppressWarnings("static-access") public class FMLLog { private static cpw.mods.fml.relauncher.FMLRelaunchLog coreLog = cpw.mods.fml.relauncher.FMLRelaunchLog.log; - public static void log(String logChannel, Level level, String format, Object... data) + public static void log(String targetLog, Level level, String format, Object... data) { - coreLog.log(logChannel, level, format, data); + coreLog.log(targetLog, level, format, data); } public static void log(Level level, String format, Object... data) @@ -30,9 +30,9 @@ public class FMLLog coreLog.log(level, format, data); } - public static void log(String logChannel, Level level, Throwable ex, String format, Object... data) + public static void log(String targetLog, Level level, Throwable ex, String format, Object... data) { - coreLog.log(logChannel, level, ex, format, data); + coreLog.log(targetLog, level, ex, format, data); } public static void log(Level level, Throwable ex, String format, Object... data) @@ -42,12 +42,12 @@ public class FMLLog public static void severe(String format, Object... data) { - log(Level.SEVERE, format, data); + log(Level.ERROR, format, data); } public static void warning(String format, Object... data) { - log(Level.WARNING, format, data); + log(Level.WARN, format, data); } public static void info(String format, Object... data) @@ -57,25 +57,16 @@ public class FMLLog public static void fine(String format, Object... data) { - log(Level.FINE, format, data); + log(Level.DEBUG, format, data); } public static void finer(String format, Object... data) { - log(Level.FINER, format, data); + log(Level.TRACE, format, data); } - public static void finest(String format, Object... data) - { - log(Level.FINEST, format, data); - } public static Logger getLogger() { return coreLog.getLogger(); } - - public static void makeLog(String logChannel) - { - coreLog.makeLog(logChannel); - } } diff --git a/fml/src/main/java/cpw/mods/fml/common/FMLModContainer.java b/fml/src/main/java/cpw/mods/fml/common/FMLModContainer.java index 1182e8c9e..10ca67d7d 100644 --- a/fml/src/main/java/cpw/mods/fml/common/FMLModContainer.java +++ b/fml/src/main/java/cpw/mods/fml/common/FMLModContainer.java @@ -24,7 +24,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; @@ -170,11 +170,11 @@ public class FMLModContainer implements ModContainer modMetadata.requiredMods = requirements; modMetadata.dependencies = dependencies; modMetadata.dependants = dependants; - FMLLog.log(getModId(), Level.FINEST, "Parsed dependency info : %s %s %s", requirements, dependencies, dependants); + FMLLog.log(getModId(), Level.TRACE, "Parsed dependency info : %s %s %s", requirements, dependencies, dependants); } else { - FMLLog.log(getModId(), Level.FINEST, "Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants); + FMLLog.log(getModId(), Level.TRACE, "Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants); } if (Strings.isNullOrEmpty(modMetadata.name)) { @@ -188,18 +188,18 @@ public class FMLModContainer implements ModContainer if (versionProps != null) { internalVersion = versionProps.getProperty(getModId()+".version"); - FMLLog.log(getModId(), Level.FINE, "Found version %s for mod %s in version.properties, using", internalVersion, getModId()); + FMLLog.log(getModId(), Level.DEBUG, "Found version %s for mod %s in version.properties, using", internalVersion, getModId()); } } if (Strings.isNullOrEmpty(internalVersion) && !Strings.isNullOrEmpty(modMetadata.version)) { - FMLLog.log(getModId(), Level.WARNING, "Mod %s is missing the required element 'version' and a version.properties file could not be found. Falling back to metadata version %s", getModId(), modMetadata.version); + FMLLog.log(getModId(), Level.WARN, "Mod %s is missing the required element 'version' and a version.properties file could not be found. Falling back to metadata version %s", getModId(), modMetadata.version); internalVersion = modMetadata.version; } if (Strings.isNullOrEmpty(internalVersion)) { - FMLLog.log(getModId(), Level.WARNING, "Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId()); + FMLLog.log(getModId(), Level.WARN, "Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId()); modMetadata.version = internalVersion = "1.0"; } @@ -218,7 +218,7 @@ public class FMLModContainer implements ModContainer { try { - FMLLog.log(getModId(), Level.FINE,"Attempting to load the file version.properties from %s to locate a version number for %s", getSource().getName(), getModId()); + FMLLog.log(getModId(), Level.DEBUG,"Attempting to load the file version.properties from %s to locate a version number for %s", getSource().getName(), getModId()); Properties version = null; if (getSource().isFile()) { @@ -247,7 +247,7 @@ public class FMLModContainer implements ModContainer catch (Exception e) { Throwables.propagateIfPossible(e); - FMLLog.log(getModId(), Level.FINEST, "Failed to find a usable version.properties file"); + FMLLog.log(getModId(), Level.TRACE, "Failed to find a usable version.properties file"); return null; } } @@ -299,7 +299,7 @@ public class FMLModContainer implements ModContainer { if (this.enabled) { - FMLLog.log(getModId(), Level.FINE, "Enabling mod %s", getModId()); + FMLLog.log(getModId(), Level.DEBUG, "Enabling mod %s", getModId()); this.eventBus = bus; this.controller = controller; eventBus.register(this); @@ -328,7 +328,7 @@ public class FMLModContainer implements ModContainer } else { - FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName()); + FMLLog.log(getModId(), Level.ERROR,"The mod %s appears to have an invalid event annotation %s. This annotation can only apply to methods with recognized event arguments - it will not be called", getModId(), a.annotationType().getSimpleName()); } } else if (a.annotationType().equals(Mod.InstanceFactory.class)) @@ -340,11 +340,11 @@ public class FMLModContainer implements ModContainer } else if (!(Modifier.isStatic(m.getModifiers()) && m.getParameterTypes().length == 0)) { - FMLLog.log(getModId(), Level.SEVERE, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes())); + FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only apply to a static method, taking zero arguments - it will be ignored on %s(%s)", m.getName(), Arrays.asList(m.getParameterTypes())); } else if (factoryMethod != null) { - FMLLog.log(getModId(), Level.SEVERE, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes())); + FMLLog.log(getModId(), Level.ERROR, "The InstanceFactory annotation can only be used once, the application to %s(%s) will be ignored", m.getName(), Arrays.asList(m.getParameterTypes())); } } } @@ -408,7 +408,7 @@ public class FMLModContainer implements ModContainer catch (Exception e) { Throwables.propagateIfPossible(e); - FMLLog.log(getModId(), Level.WARNING, e, "Attempting to load @%s in class %s for %s and failing", annotationName, targets.getClassName(), mc.getModId()); + FMLLog.log(getModId(), Level.WARN, e, "Attempting to load @%s in class %s for %s and failing", annotationName, targets.getClassName(), mc.getModId()); } } if (f != null) @@ -419,7 +419,7 @@ public class FMLModContainer implements ModContainer target = modInstance; if (!modInstance.getClass().equals(clz)) { - FMLLog.log(getModId(), Level.WARNING, "Unable to inject @%s in non-static field %s.%s for %s as it is NOT the primary mod instance", annotationName, targets.getClassName(), targets.getObjectName(), mc.getModId()); + FMLLog.log(getModId(), Level.WARN, "Unable to inject @%s in non-static field %s.%s for %s as it is NOT the primary mod instance", annotationName, targets.getClassName(), targets.getObjectName(), mc.getModId()); continue; } } @@ -461,10 +461,10 @@ public class FMLModContainer implements ModContainer { if (!sourceFingerprints.contains(expectedFingerprint)) { - Level warnLevel = Level.SEVERE; + Level warnLevel = Level.ERROR; if (source.isDirectory()) { - warnLevel = Level.FINER; + warnLevel = Level.TRACE; } FMLLog.log(getModId(), warnLevel, "The mod %s is expecting signature %s for source %s, however there is no signature matching that description", getModId(), expectedFingerprint, source.getName()); } diff --git a/fml/src/main/java/cpw/mods/fml/common/ILanguageAdapter.java b/fml/src/main/java/cpw/mods/fml/common/ILanguageAdapter.java index 86d3644a6..9b0c4381b 100644 --- a/fml/src/main/java/cpw/mods/fml/common/ILanguageAdapter.java +++ b/fml/src/main/java/cpw/mods/fml/common/ILanguageAdapter.java @@ -3,7 +3,7 @@ package cpw.mods.fml.common; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import cpw.mods.fml.relauncher.Side; @@ -90,7 +90,7 @@ public interface ILanguageAdapter { } catch (InvocationTargetException e) { - FMLLog.log(Level.SEVERE, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); + FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); throw new LoaderException(e); } @@ -147,7 +147,7 @@ public interface ILanguageAdapter { setProxy(target, proxyTarget, proxy); } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); + FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", proxyTarget.getSimpleName(), target.getName()); throw new LoaderException(e); } } diff --git a/fml/src/main/java/cpw/mods/fml/common/LoadController.java b/fml/src/main/java/cpw/mods/fml/common/LoadController.java index c6bf97981..531c2cc33 100644 --- a/fml/src/main/java/cpw/mods/fml/common/LoadController.java +++ b/fml/src/main/java/cpw/mods/fml/common/LoadController.java @@ -16,8 +16,8 @@ import java.lang.reflect.InvocationTargetException; import java.util.Collection; import java.util.List; import java.util.Map.Entry; -import java.util.logging.Level; -import java.util.logging.Logger; + +import org.apache.logging.log4j.Level; import com.google.common.base.Joiner; import com.google.common.collect.ArrayListMultimap; @@ -39,7 +39,6 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLStateEvent; import cpw.mods.fml.common.functions.ArtifactVersionNameFunction; import cpw.mods.fml.common.versioning.ArtifactVersion; -import cpw.mods.fml.relauncher.FMLRelaunchLog; public class LoadController { @@ -72,18 +71,10 @@ public class LoadController for (ModContainer mod : loader.getModList()) { //Create mod logger, and make the EventBus logger a child of it. - FMLRelaunchLog.makeLog(mod.getModId()); - Logger modLogger = Logger.getLogger(mod.getModId()); - Logger eventLog = Logger.getLogger(EventBus.class.getName() + "." + mod.getModId()); - eventLog.setParent(modLogger); - EventBus bus = new EventBus(mod.getModId()); boolean isActive = mod.registerBus(bus, this); if (isActive) { - Level level = Logger.getLogger(mod.getModId()).getLevel(); - FMLLog.log(mod.getModId(), Level.FINE, "Mod Logging channel %s configured at %s level.", mod.getModId(), level == null ? "default" : level); - FMLLog.log(mod.getModId(), Level.INFO, "Activating mod %s", mod.getModId()); activeModList.add(mod); modStates.put(mod.getModId(), ModState.UNLOADED); eventBus.put(mod.getModId(), bus); @@ -91,7 +82,7 @@ public class LoadController } else { - FMLLog.log(mod.getModId(), Level.WARNING, "Mod %s has been disabled through configuration", mod.getModId()); + FMLLog.log(mod.getModId(), Level.WARN, "Mod %s has been disabled through configuration", mod.getModId()); modStates.put(mod.getModId(), ModState.UNLOADED); modStates.put(mod.getModId(), ModState.DISABLED); } @@ -119,13 +110,13 @@ public class LoadController FMLLog.severe("Fatal errors were detected during the transition from %s to %s. Loading cannot continue", oldState, desiredState); StringBuilder sb = new StringBuilder(); printModStates(sb); - FMLLog.getLogger().severe(sb.toString()); + FMLLog.severe(sb.toString()); if (errors.size()>0) { FMLLog.severe("The following problems were captured during this phase"); for (Entry error : errors.entries()) { - FMLLog.log(Level.SEVERE, error.getValue(), "Caught exception from %s", error.getKey()); + FMLLog.log(Level.ERROR, error.getValue(), "Caught exception from %s", error.getKey()); if (error.getValue() instanceof IFMLHandledException) { toThrow = error.getValue(); @@ -186,16 +177,16 @@ public class LoadController { if (av.getLabel()!= null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(),ModState.ERRORED)) { - FMLLog.log(modId, Level.SEVERE, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel()); + FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel()); modStates.put(modId, ModState.ERRORED); return; } } activeContainer = mc; stateEvent.applyModContainer(activeContainer()); - FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId); + FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId); eventChannels.get(modId).post(stateEvent); - FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId); + FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId); activeContainer = null; if (stateEvent instanceof FMLStateEvent) { @@ -270,7 +261,7 @@ public class LoadController } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "An unexpected exception"); + FMLLog.log(Level.ERROR, e, "An unexpected exception"); throw new LoaderException(e); } } diff --git a/fml/src/main/java/cpw/mods/fml/common/Loader.java b/fml/src/main/java/cpw/mods/fml/common/Loader.java index 737610638..bcb0cca6e 100644 --- a/fml/src/main/java/cpw/mods/fml/common/Loader.java +++ b/fml/src/main/java/cpw/mods/fml/common/Loader.java @@ -22,7 +22,8 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.logging.Level; + +import org.apache.logging.log4j.Level; import com.google.common.base.CharMatcher; import com.google.common.base.Function; @@ -57,7 +58,6 @@ import cpw.mods.fml.common.toposort.ModSortingException.SortingExceptionData; import cpw.mods.fml.common.toposort.TopologicalSort; import cpw.mods.fml.common.versioning.ArtifactVersion; import cpw.mods.fml.common.versioning.VersionParser; -import cpw.mods.fml.relauncher.FMLRelaunchLog; import cpw.mods.fml.relauncher.Side; /** @@ -132,7 +132,6 @@ public class Loader private static File minecraftDir; private static List injectedContainers; - private File loggingProperties; private ImmutableMap fmlBrandingProperties; public static Loader instance() @@ -252,7 +251,7 @@ public class Loader { FMLLog.severe("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()); } - FMLLog.log(Level.SEVERE, sortException, "The full error"); + FMLLog.log(Level.ERROR, sortException, "The full error"); throw sortException; } } @@ -304,7 +303,7 @@ public class Loader } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "A problem occured instantiating the injected mod container %s", cont); + FMLLog.log(Level.ERROR, e, "A problem occured instantiating the injected mod container %s", cont); throw new LoaderException(e); } mods.add(new InjectedModContainer(mc,mc.getSource())); @@ -327,10 +326,6 @@ public class Loader identifyDuplicates(mods); namedMods = Maps.uniqueIndex(mods, new ModIdFunction()); FMLLog.info("Forge Mod Loader has identified %d mod%s to load", mods.size(), mods.size() != 1 ? "s" : ""); - for (String modId: namedMods.keySet()) - { - FMLLog.makeLog(modId); - } return discoverer; } @@ -389,7 +384,7 @@ public class Loader } catch (IOException ioe) { - FMLLog.log(Level.SEVERE, ioe, "Failed to resolve loader directories: mods : %s ; config %s", canonicalModsDir.getAbsolutePath(), + FMLLog.log(Level.ERROR, ioe, "Failed to resolve loader directories: mods : %s ; config %s", canonicalModsDir.getAbsolutePath(), configDir.getAbsolutePath()); throw new LoaderException(ioe); } @@ -429,11 +424,6 @@ public class Loader FMLLog.severe("Attempting to load configuration from %s, which is not a directory", canonicalConfigPath); throw new LoaderException(); } - - loggingProperties = new File(canonicalConfigDir, "logging.properties"); - FMLLog.info("Reading custom logging properties from %s", loggingProperties.getPath()); - FMLRelaunchLog.loadLogConfiguration(loggingProperties); - FMLLog.log(Level.OFF,"Logging level for ForgeModLoader logging is set to %s", FMLRelaunchLog.log.getLogger().getLevel()); } public List getModList() @@ -457,9 +447,6 @@ public class Loader ModDiscoverer disc = identifyMods(); ModAPIManager.INSTANCE.manageAPI(modClassLoader, disc); disableRequestedMods(); - FMLLog.fine("Reloading logging properties from %s", loggingProperties.getPath()); - FMLRelaunchLog.loadLogConfiguration(loggingProperties); - FMLLog.fine("Reloaded logging properties"); modController.distributeStateMessage(FMLLoadEvent.class); sortModList(); ModAPIManager.INSTANCE.cleanupAPIContainers(modController.getActiveModList()); @@ -476,7 +463,7 @@ public class Loader } catch (MalformedURLException e) { - FMLLog.log(Level.SEVERE, e, "Encountered a weird problem with non-mod file injection : %s", nonMod.getName()); + FMLLog.log(Level.ERROR, e, "Encountered a weird problem with non-mod file injection : %s", nonMod.getName()); } } } @@ -655,7 +642,7 @@ public class Loader if (parseFailure) { - FMLLog.log(Level.WARNING, "Unable to parse dependency string %s", dependencyString); + FMLLog.log(Level.WARN, "Unable to parse dependency string %s", dependencyString); throw new LoaderException(); } } @@ -720,7 +707,7 @@ public class Loader } catch (Throwable t) { - FMLLog.log(Level.SEVERE, t, "A fatal exception occurred during the server starting event"); + FMLLog.log(Level.ERROR, t, "A fatal exception occurred during the server starting event"); return false; } return true; @@ -789,7 +776,7 @@ public class Loader } catch (Throwable t) { - FMLLog.log(Level.SEVERE, t, "A fatal exception occurred during the server about to start event"); + FMLLog.log(Level.ERROR, t, "A fatal exception occurred during the server about to start event"); return false; } return true; @@ -843,7 +830,7 @@ public class Loader { if (remaps.isEmpty()) { - FMLLog.finest("Skipping remap event - no remaps occured"); + FMLLog.finer("Skipping remap event - no remaps occured"); } else { diff --git a/fml/src/main/java/cpw/mods/fml/common/MetadataCollection.java b/fml/src/main/java/cpw/mods/fml/common/MetadataCollection.java index 6adca4e0a..d83f92fad 100644 --- a/fml/src/main/java/cpw/mods/fml/common/MetadataCollection.java +++ b/fml/src/main/java/cpw/mods/fml/common/MetadataCollection.java @@ -15,7 +15,7 @@ package cpw.mods.fml.common; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Map; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import com.google.common.base.Throwables; import com.google.common.collect.Maps; @@ -66,7 +66,7 @@ public class MetadataCollection } catch (JsonParseException e) { - FMLLog.log(Level.SEVERE, e, "The mcmod.info file in %s cannot be parsed as valid JSON. It will be ignored", sourceName); + FMLLog.log(Level.ERROR, e, "The mcmod.info file in %s cannot be parsed as valid JSON. It will be ignored", sourceName); return new MetadataCollection(); } catch (Exception e) diff --git a/fml/src/main/java/cpw/mods/fml/common/Mod.java b/fml/src/main/java/cpw/mods/fml/common/Mod.java index ddbd60bc9..9d9ebf18b 100644 --- a/fml/src/main/java/cpw/mods/fml/common/Mod.java +++ b/fml/src/main/java/cpw/mods/fml/common/Mod.java @@ -144,6 +144,15 @@ public @interface Mod @Deprecated String asmHookClass() default ""; + /** + * If your mod doesn't have a runtime persistent effect on the state of the game, and can be disabled without side effects + * (minimap mods, graphical tweak mods) then you can set true here and receive the FMLDeactivationEvent to perform deactivation + * tasks. + * This does not affect administrative disabling through the system property fml.modStates or the config file fmlModState.properties. + * + * @return if I can be deactivated whilst the game is running. + */ + boolean canBeDeactivated() default false; /** * A list of custom properties for this mod. Completely up to the mod author if/when they * want to put anything in here. diff --git a/fml/src/main/java/cpw/mods/fml/common/ModAPIManager.java b/fml/src/main/java/cpw/mods/fml/common/ModAPIManager.java index 81c87924e..9e581063d 100644 --- a/fml/src/main/java/cpw/mods/fml/common/ModAPIManager.java +++ b/fml/src/main/java/cpw/mods/fml/common/ModAPIManager.java @@ -181,7 +181,7 @@ public class ModAPIManager { do { APIContainer parent = apiContainers.get(owner.getLabel()); - FMLLog.finest("Removing upstream parent %s from %s", parent.ownerMod.getLabel(), container); + FMLLog.finer("Removing upstream parent %s from %s", parent.ownerMod.getLabel(), container); container.currentReferents.remove(parent.ownerMod.getLabel()); container.referredMods.remove(parent.ownerMod); owner = parent.ownerMod; diff --git a/fml/src/main/java/cpw/mods/fml/common/ModClassLoader.java b/fml/src/main/java/cpw/mods/fml/common/ModClassLoader.java index 527efcbcd..f6c02f142 100644 --- a/fml/src/main/java/cpw/mods/fml/common/ModClassLoader.java +++ b/fml/src/main/java/cpw/mods/fml/common/ModClassLoader.java @@ -19,7 +19,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.List; import java.util.Set; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import net.minecraft.launchwrapper.IClassTransformer; import net.minecraft.launchwrapper.LaunchClassLoader; @@ -71,7 +71,7 @@ public class ModClassLoader extends URLClassLoader } catch (URISyntaxException e) { - FMLLog.log(Level.SEVERE, e, "Unable to process our input to locate the minecraft code"); + FMLLog.log(Level.ERROR, e, "Unable to process our input to locate the minecraft code"); throw new LoaderException(e); } } diff --git a/fml/src/main/java/cpw/mods/fml/common/ObfuscationReflectionHelper.java b/fml/src/main/java/cpw/mods/fml/common/ObfuscationReflectionHelper.java index 181b9a45e..1f2310cf5 100644 --- a/fml/src/main/java/cpw/mods/fml/common/ObfuscationReflectionHelper.java +++ b/fml/src/main/java/cpw/mods/fml/common/ObfuscationReflectionHelper.java @@ -13,7 +13,7 @@ package cpw.mods.fml.common; import java.util.Arrays; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper; import cpw.mods.fml.relauncher.ReflectionHelper; @@ -36,7 +36,7 @@ public class ObfuscationReflectionHelper } catch (UnableToAccessFieldException e) { - FMLLog.log(Level.SEVERE, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName()); + FMLLog.log(Level.ERROR, e, "There was a problem getting field index %d from %s", fieldIndex, classToAccess.getName()); throw e; } } @@ -61,12 +61,12 @@ public class ObfuscationReflectionHelper } catch (UnableToFindFieldException e) { - FMLLog.log(Level.SEVERE,e,"Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); + FMLLog.log(Level.ERROR,e,"Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); throw e; } catch (UnableToAccessFieldException e) { - FMLLog.log(Level.SEVERE, e, "Unable to access any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); + FMLLog.log(Level.ERROR, e, "Unable to access any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); throw e; } } @@ -79,7 +79,7 @@ public class ObfuscationReflectionHelper } catch (UnableToAccessFieldException e) { - FMLLog.log(Level.SEVERE, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName()); + FMLLog.log(Level.ERROR, e, "There was a problem setting field index %d on type %s", fieldIndex, classToAccess.getName()); throw e; } } @@ -92,12 +92,12 @@ public class ObfuscationReflectionHelper } catch (UnableToFindFieldException e) { - FMLLog.log(Level.SEVERE, e, "Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); + FMLLog.log(Level.ERROR, e, "Unable to locate any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); throw e; } catch (UnableToAccessFieldException e) { - FMLLog.log(Level.SEVERE, e, "Unable to set any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); + FMLLog.log(Level.ERROR, e, "Unable to set any field %s on type %s", Arrays.toString(fieldNames), classToAccess.getName()); throw e; } } diff --git a/fml/src/main/java/cpw/mods/fml/common/ProxyInjector.java b/fml/src/main/java/cpw/mods/fml/common/ProxyInjector.java index fe1716523..9920ec550 100644 --- a/fml/src/main/java/cpw/mods/fml/common/ProxyInjector.java +++ b/fml/src/main/java/cpw/mods/fml/common/ProxyInjector.java @@ -15,7 +15,7 @@ package cpw.mods.fml.common; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.Set; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import com.google.common.base.Strings; @@ -71,7 +71,7 @@ public class ProxyInjector } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "An error occured trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName()); + FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName()); throw new LoaderException(e); } } diff --git a/fml/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java b/fml/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java index 0e9b0a173..da230a00e 100644 --- a/fml/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java +++ b/fml/src/main/java/cpw/mods/fml/common/asm/FMLSanityChecker.java @@ -20,7 +20,7 @@ import java.security.cert.Certificate; import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import net.minecraft.launchwrapper.LaunchClassLoader; @@ -123,7 +123,7 @@ public class FMLSanityChecker implements IFMLCallHook } catch (Throwable e) { - FMLRelaunchLog.log(Level.SEVERE, e, "A critical error occurred trying to read the minecraft jar file"); + FMLRelaunchLog.log(Level.ERROR, e, "A critical error occurred trying to read the minecraft jar file"); } finally { diff --git a/fml/src/main/java/cpw/mods/fml/common/asm/transformers/AccessTransformer.java b/fml/src/main/java/cpw/mods/fml/common/asm/transformers/AccessTransformer.java index 8573c6ec5..efb919ed3 100644 --- a/fml/src/main/java/cpw/mods/fml/common/asm/transformers/AccessTransformer.java +++ b/fml/src/main/java/cpw/mods/fml/common/asm/transformers/AccessTransformer.java @@ -155,7 +155,7 @@ public class AccessTransformer implements IClassTransformer return true; } }); - System.out.printf("Loaded %d rules from AccessTransformer config file %s\n", modifiers.size(), rulesFile); + FMLRelaunchLog.fine("Loaded %d rules from AccessTransformer config file %s\n", modifiers.size(), rulesFile); } @Override diff --git a/fml/src/main/java/cpw/mods/fml/common/asm/transformers/ModAPITransformer.java b/fml/src/main/java/cpw/mods/fml/common/asm/transformers/ModAPITransformer.java index 57892a9f9..7fdff2063 100644 --- a/fml/src/main/java/cpw/mods/fml/common/asm/transformers/ModAPITransformer.java +++ b/fml/src/main/java/cpw/mods/fml/common/asm/transformers/ModAPITransformer.java @@ -39,17 +39,17 @@ public class ModAPITransformer implements IClassTransformer { ClassReader classReader = new ClassReader(basicClass); classReader.accept(classNode, 0); - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal - found optionals for class %s - processing", name); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - found optionals for class %s - processing", name); for (ASMData optional : optionals.get(name)) { String modId = (String) optional.getAnnotationInfo().get("modid"); if (Loader.isModLoaded(modId) || ModAPIManager.INSTANCE.hasAPI(modId)) { - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal skipped - mod present %s", modId); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal skipped - mod present %s", modId); continue; } - if (logDebugInfo) FMLRelaunchLog.finest("Optional on %s triggered - mod missing %s", name, modId); + if (logDebugInfo) FMLRelaunchLog.finer("Optional on %s triggered - mod missing %s", name, modId); if (optional.getAnnotationInfo().containsKey("iface")) { @@ -63,7 +63,7 @@ public class ModAPITransformer implements IClassTransformer { } } - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal - class %s processed", name); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - class %s processed", name); ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); classNode.accept(writer); @@ -78,37 +78,37 @@ public class ModAPITransformer implements IClassTransformer { if (methodDescriptor.equals(method.name+method.desc)) { iterator.remove(); - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal - method %s removed", methodDescriptor); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - method %s removed", methodDescriptor); return; } } - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal - method %s NOT removed - not found", methodDescriptor); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - method %s NOT removed - not found", methodDescriptor); } private void stripInterface(ClassNode classNode, String interfaceName, boolean stripRefs) { String ifaceName = interfaceName.replace('.', '/'); boolean found = classNode.interfaces.remove(ifaceName); - if (found && logDebugInfo) FMLRelaunchLog.finest("Optional removal - interface %s removed", interfaceName); - if (!found && logDebugInfo) FMLRelaunchLog.finest("Optional removal - interface %s NOT removed - not found", interfaceName); + if (found && logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s removed", interfaceName); + if (!found && logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s NOT removed - not found", interfaceName); if (found && stripRefs) { - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal - interface %s - stripping method signature references", interfaceName); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - stripping method signature references", interfaceName); for (Iterator iterator = classNode.methods.iterator(); iterator.hasNext();) { MethodNode node = iterator.next(); if (node.desc.contains(ifaceName)) { - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal - interface %s - stripping method containing reference %s", interfaceName, node.name); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - stripping method containing reference %s", interfaceName, node.name); iterator.remove(); } } - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal - interface %s - all method signature references stripped", interfaceName); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - all method signature references stripped", interfaceName); } else if (found) { - if (logDebugInfo) FMLRelaunchLog.finest("Optional removal - interface %s - NOT stripping method signature references", interfaceName); + if (logDebugInfo) FMLRelaunchLog.finer("Optional removal - interface %s - NOT stripping method signature references", interfaceName); } } diff --git a/fml/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java b/fml/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java index ebc7a8dbf..f8788b077 100644 --- a/fml/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java +++ b/fml/src/main/java/cpw/mods/fml/common/asm/transformers/deobf/FMLDeobfuscatingRemapper.java @@ -21,11 +21,10 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; import net.minecraft.launchwrapper.LaunchClassLoader; +import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; import org.objectweb.asm.commons.Remapper; import org.objectweb.asm.tree.ClassNode; @@ -47,7 +46,6 @@ import com.google.common.collect.Sets; import com.google.common.io.CharStreams; import com.google.common.io.InputSupplier; -import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.patcher.ClassPatchManager; import cpw.mods.fml.relauncher.FMLRelaunchLog; @@ -112,7 +110,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { } catch (IOException ioe) { - Logger.getLogger("FML").log(Level.SEVERE, "An error occurred loading the deobfuscation map data", ioe); + FMLRelaunchLog.log(Level.ERROR, "An error occurred loading the deobfuscation map data", ioe); } methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size()); fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size()); @@ -161,7 +159,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { } catch (IOException ioe) { - FMLRelaunchLog.log(Level.SEVERE, ioe, "An error occurred loading the deobfuscation map data"); + FMLRelaunchLog.log(Level.ERROR, ioe, "An error occurred loading the deobfuscation map data"); } methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size()); fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size()); @@ -226,7 +224,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { } catch (IOException e) { - FMLLog.log(Level.SEVERE,e, "A critical exception occured reading a class file %s", owner); + FMLRelaunchLog.log(Level.ERROR,e, "A critical exception occured reading a class file %s", owner); } return null; } @@ -337,7 +335,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { if (DUMP_FIELD_MAPS) { - FMLRelaunchLog.finest("Field map for %s : %s", className, fieldNameMaps.get(className)); + FMLRelaunchLog.finer("Field map for %s : %s", className, fieldNameMaps.get(className)); } } return fieldNameMaps.get(className); @@ -354,7 +352,7 @@ public class FMLDeobfuscatingRemapper extends Remapper { } if (DUMP_METHOD_MAPS) { - FMLRelaunchLog.finest("Method map for %s : %s", className, methodNameMaps.get(className)); + FMLRelaunchLog.finer("Method map for %s : %s", className, methodNameMaps.get(className)); } } diff --git a/fml/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java b/fml/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java index cf22b6c0e..199ec600f 100644 --- a/fml/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java +++ b/fml/src/main/java/cpw/mods/fml/common/discovery/DirectoryDiscoverer.java @@ -17,9 +17,10 @@ import java.io.FileFilter; import java.io.FileInputStream; import java.util.Arrays; import java.util.List; -import java.util.logging.Level; import java.util.regex.Matcher; +import org.apache.logging.log4j.Level; + import com.google.common.base.Throwables; import com.google.common.collect.Lists; @@ -84,7 +85,7 @@ public class DirectoryDiscoverer implements ITypeDiscoverer { if (file.isDirectory()) { - FMLLog.finest("Recursing into package %s", path + file.getName()); + FMLLog.finer("Recursing into package %s", path + file.getName()); exploreFileSystem(path + file.getName() + ".", file, harvestedMods, candidate, mc); continue; } @@ -102,7 +103,7 @@ public class DirectoryDiscoverer implements ITypeDiscoverer } catch (LoaderException e) { - FMLLog.log(Level.SEVERE, e, "There was a problem reading the file %s - probably this is a corrupt file", file.getPath()); + FMLLog.log(Level.ERROR, e, "There was a problem reading the file %s - probably this is a corrupt file", file.getPath()); throw e; } catch (Exception e) diff --git a/fml/src/main/java/cpw/mods/fml/common/discovery/JarDiscoverer.java b/fml/src/main/java/cpw/mods/fml/common/discovery/JarDiscoverer.java index ecc79c5a6..7b331f1df 100644 --- a/fml/src/main/java/cpw/mods/fml/common/discovery/JarDiscoverer.java +++ b/fml/src/main/java/cpw/mods/fml/common/discovery/JarDiscoverer.java @@ -15,7 +15,7 @@ package cpw.mods.fml.common.discovery; import java.util.Collections; import java.util.List; import java.util.jar.JarFile; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import java.util.regex.Matcher; import java.util.zip.ZipEntry; @@ -42,7 +42,7 @@ public class JarDiscoverer implements ITypeDiscoverer if (jar.getManifest()!=null && (jar.getManifest().getMainAttributes().get("FMLCorePlugin") != null || jar.getManifest().getMainAttributes().get("TweakClass") != null)) { - FMLLog.finest("Ignoring coremod or tweak system %s", candidate.getModContainer()); + FMLLog.finer("Ignoring coremod or tweak system %s", candidate.getModContainer()); return foundMods; } ZipEntry modInfo = jar.getEntry("mcmod.info"); @@ -74,7 +74,7 @@ public class JarDiscoverer implements ITypeDiscoverer } catch (LoaderException e) { - FMLLog.log(Level.SEVERE, e, "There was a problem reading the entry %s in the jar %s - probably a corrupt zip", ze.getName(), candidate.getModContainer().getPath()); + FMLLog.log(Level.ERROR, e, "There was a problem reading the entry %s in the jar %s - probably a corrupt zip", ze.getName(), candidate.getModContainer().getPath()); jar.close(); throw e; } @@ -92,7 +92,7 @@ public class JarDiscoverer implements ITypeDiscoverer } catch (Exception e) { - FMLLog.log(Level.WARNING, e, "Zip file %s failed to read properly, it will be ignored", candidate.getModContainer().getName()); + FMLLog.log(Level.WARN, e, "Zip file %s failed to read properly, it will be ignored", candidate.getModContainer().getName()); } finally { diff --git a/fml/src/main/java/cpw/mods/fml/common/discovery/ModDiscoverer.java b/fml/src/main/java/cpw/mods/fml/common/discovery/ModDiscoverer.java index da7e87ccc..c7ab8057f 100644 --- a/fml/src/main/java/cpw/mods/fml/common/discovery/ModDiscoverer.java +++ b/fml/src/main/java/cpw/mods/fml/common/discovery/ModDiscoverer.java @@ -16,7 +16,7 @@ import java.io.File; import java.util.Arrays; import java.util.Comparator; import java.util.List; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -143,7 +143,7 @@ public class ModDiscoverer } catch (LoaderException le) { - FMLLog.log(Level.WARNING, le, "Identified a problem with the mod candidate %s, ignoring this source", candidate.getModContainer()); + FMLLog.log(Level.WARN, le, "Identified a problem with the mod candidate %s, ignoring this source", candidate.getModContainer()); } catch (Throwable t) { diff --git a/fml/src/main/java/cpw/mods/fml/common/discovery/asm/ASMModParser.java b/fml/src/main/java/cpw/mods/fml/common/discovery/asm/ASMModParser.java index 116ed75fe..9e2ad8090 100644 --- a/fml/src/main/java/cpw/mods/fml/common/discovery/asm/ASMModParser.java +++ b/fml/src/main/java/cpw/mods/fml/common/discovery/asm/ASMModParser.java @@ -17,8 +17,8 @@ import java.io.InputStream; import java.util.Collections; import java.util.LinkedList; import java.util.List; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import org.objectweb.asm.ClassReader; import org.objectweb.asm.Type; @@ -54,7 +54,7 @@ public class ASMModParser } catch (Exception ex) { - FMLLog.log(Level.SEVERE, ex, "Unable to read a class file correctly"); + FMLLog.log(Level.ERROR, ex, "Unable to read a class file correctly"); throw new LoaderException(ex); } } diff --git a/fml/src/main/java/cpw/mods/fml/common/event/FMLInterModComms.java b/fml/src/main/java/cpw/mods/fml/common/event/FMLInterModComms.java index 6a72b9d68..00542a50e 100644 --- a/fml/src/main/java/cpw/mods/fml/common/event/FMLInterModComms.java +++ b/fml/src/main/java/cpw/mods/fml/common/event/FMLInterModComms.java @@ -51,7 +51,7 @@ public class FMLInterModComms { { this.activeContainer = activeContainer; this.currentList = null; - FMLLog.finest("Attempting to deliver %d IMC messages to mod %s", modMessages.get(activeContainer.getModId()).size(), activeContainer.getModId()); + FMLLog.finer("Attempting to deliver %d IMC messages to mod %s", modMessages.get(activeContainer.getModId()).size(), activeContainer.getModId()); } private ImmutableList currentList; diff --git a/fml/src/main/java/cpw/mods/fml/common/event/FMLPreInitializationEvent.java b/fml/src/main/java/cpw/mods/fml/common/event/FMLPreInitializationEvent.java index 7cf710b2a..1851b2fdb 100644 --- a/fml/src/main/java/cpw/mods/fml/common/event/FMLPreInitializationEvent.java +++ b/fml/src/main/java/cpw/mods/fml/common/event/FMLPreInitializationEvent.java @@ -5,7 +5,7 @@ * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * + * * Contributors: * cpw - implementation */ @@ -16,9 +16,10 @@ import java.io.File; import java.security.CodeSource; import java.security.cert.Certificate; import java.util.Properties; -import java.util.logging.Logger; -import cpw.mods.fml.common.FMLLog; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import cpw.mods.fml.common.LoaderState.ModState; import cpw.mods.fml.common.FMLModContainer; import cpw.mods.fml.common.ModContainer; @@ -100,8 +101,7 @@ public class FMLPreInitializationEvent extends FMLStateEvent */ public Logger getModLog() { - Logger log = Logger.getLogger(modContainer.getModId()); - log.setParent(FMLLog.getLogger()); + Logger log = LogManager.getLogger(modContainer.getModId()); return log; } diff --git a/fml/src/main/java/cpw/mods/fml/common/launcher/FMLDeobfTweaker.java b/fml/src/main/java/cpw/mods/fml/common/launcher/FMLDeobfTweaker.java index 0a43444c9..c5e6be955 100644 --- a/fml/src/main/java/cpw/mods/fml/common/launcher/FMLDeobfTweaker.java +++ b/fml/src/main/java/cpw/mods/fml/common/launcher/FMLDeobfTweaker.java @@ -4,6 +4,7 @@ import java.io.File; import java.lang.reflect.Method; import java.util.List; +import cpw.mods.fml.relauncher.CoreModManager; import cpw.mods.fml.relauncher.FMLInjectionData; import cpw.mods.fml.relauncher.FMLRelaunchLog; @@ -25,7 +26,11 @@ public class FMLDeobfTweaker implements ITweaker { { classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer"); } - classLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.AccessTransformer"); + // Add all the access transformers now as well + for (String transformer : CoreModManager.getAccessTransformers()) + { + classLoader.registerTransformer(transformer); + } try { FMLRelaunchLog.fine("Validating minecraft"); diff --git a/fml/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java b/fml/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java index 23cd9665c..2ecf26b35 100644 --- a/fml/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java +++ b/fml/src/main/java/cpw/mods/fml/common/launcher/FMLTweaker.java @@ -6,13 +6,14 @@ import java.net.URISyntaxException; import java.util.List; import java.util.Map; import java.util.Map.Entry; -import java.util.logging.Level; -import java.util.logging.Logger; import net.minecraft.launchwrapper.ITweaker; import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.LaunchClassLoader; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; + import com.google.common.base.Throwables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; @@ -102,7 +103,7 @@ public class FMLTweaker implements ITweaker { } catch (URISyntaxException e) { - Logger.getLogger("FMLTWEAK").log(Level.SEVERE, "Missing URI information for FML tweak"); + LogManager.getLogger("FMLTWEAK").log(Level.ERROR, "Missing URI information for FML tweak"); throw Throwables.propagate(e); } } @@ -110,6 +111,7 @@ public class FMLTweaker implements ITweaker { @Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { + classLoader.addClassLoaderExclusion("org.apache."); classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); diff --git a/fml/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java b/fml/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java index 58540c55b..dc27e812d 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/NetworkRegistry.java @@ -21,7 +21,7 @@ import io.netty.util.AttributeKey; import java.util.EnumMap; import java.util.Map; import java.util.Set; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; @@ -371,7 +371,7 @@ public enum NetworkRegistry ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod); if (mc == null) { - FMLLog.log(Level.SEVERE, "Mod of type %s attempted to register a gui network handler during a construction phase", mod.getClass().getName()); + FMLLog.log(Level.ERROR, "Mod of type %s attempted to register a gui network handler during a construction phase", mod.getClass().getName()); throw new RuntimeException("Invalid attempt to create a GUI during mod construction. Use an EventHandler instead"); } serverGuiHandlers.put(mc, handler); diff --git a/fml/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java b/fml/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java index bebf1fb35..f11f3820b 100644 --- a/fml/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java +++ b/fml/src/main/java/cpw/mods/fml/common/network/internal/EntitySpawnHandler.java @@ -4,7 +4,7 @@ import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import java.util.List; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.multiplayer.WorldClient; @@ -119,7 +119,7 @@ public class EntitySpawnHandler extends SimpleChannelInboundHandler reparsedCoremods = Lists.newArrayList(); + private static List accessTransformers = Lists.newArrayList(); private static class FMLPluginWrapper implements ITweaker { public final String name; @@ -96,7 +98,7 @@ public class CoreModManager { FMLRelaunchLog.fine("Injecting coremod %s {%s} class transformers", name, coreModInstance.getClass().getName()); if (coreModInstance.getASMTransformerClass() != null) for (String transformer : coreModInstance.getASMTransformerClass()) { - FMLRelaunchLog.finest("Registering transformer %s", transformer); + FMLRelaunchLog.finer("Registering transformer %s", transformer); classLoader.registerTransformer(transformer); } FMLRelaunchLog.fine("Injection complete"); @@ -181,7 +183,7 @@ public class CoreModManager { } catch (Exception e) { - FMLRelaunchLog.log(Level.SEVERE, e, "The patch transformer failed to load! This is critical, loading cannot continue!"); + FMLRelaunchLog.log(Level.ERROR, e, "The patch transformer failed to load! This is critical, loading cannot continue!"); throw Throwables.propagate(e); } @@ -251,7 +253,7 @@ public class CoreModManager { } catch (IOException ioe) { - FMLRelaunchLog.log(Level.SEVERE, ioe, "Unable to read the jar file %s - ignoring", coreMod.getName()); + FMLRelaunchLog.log(Level.ERROR, ioe, "Unable to read the jar file %s - ignoring", coreMod.getName()); continue; } finally @@ -292,19 +294,19 @@ public class CoreModManager { classLoader.addURL(coreMod.toURI().toURL()); if (!mfAttributes.containsKey(COREMODCONTAINSFMLMOD)) { - FMLRelaunchLog.finest("Adding %s to the list of known coremods, it will not be examined again", coreMod.getName()); + FMLRelaunchLog.finer("Adding %s to the list of known coremods, it will not be examined again", coreMod.getName()); loadedCoremods.add(coreMod.getName()); } else { - FMLRelaunchLog.finest("Found FMLCorePluginContainsFMLMod marker in %s, it will be examined later for regular @Mod instances", + FMLRelaunchLog.finer("Found FMLCorePluginContainsFMLMod marker in %s, it will be examined later for regular @Mod instances", coreMod.getName()); reparsedCoremods.add(coreMod.getName()); } } catch (MalformedURLException e) { - FMLRelaunchLog.log(Level.SEVERE, e, "Unable to convert file into a URL. weird"); + FMLRelaunchLog.log(Level.ERROR, e, "Unable to convert file into a URL. weird"); continue; } loadCoreMod(classLoader, fmlCorePlugin, coreMod); @@ -383,23 +385,23 @@ public class CoreModManager { if (coreModNameAnn != null && !Strings.isNullOrEmpty(coreModNameAnn.value())) { coreModName = coreModNameAnn.value(); - FMLRelaunchLog.finest("coremod named %s is loading", coreModName); + FMLRelaunchLog.finer("coremod named %s is loading", coreModName); } MCVersion requiredMCVersion = coreModClazz.getAnnotation(IFMLLoadingPlugin.MCVersion.class); if (!Arrays.asList(rootPlugins).contains(coreModClass) && (requiredMCVersion == null || Strings.isNullOrEmpty(requiredMCVersion.value()))) { - FMLRelaunchLog.log(Level.WARNING, "The coremod %s does not have a MCVersion annotation, it may cause issues with this version of Minecraft", + FMLRelaunchLog.log(Level.WARN, "The coremod %s does not have a MCVersion annotation, it may cause issues with this version of Minecraft", coreModClass); } else if (requiredMCVersion != null && !FMLInjectionData.mccversion.equals(requiredMCVersion.value())) { - FMLRelaunchLog.log(Level.SEVERE, "The coremod %s is requesting minecraft version %s and minecraft is %s. It will be ignored.", coreModClass, + FMLRelaunchLog.log(Level.ERROR, "The coremod %s is requesting minecraft version %s and minecraft is %s. It will be ignored.", coreModClass, requiredMCVersion.value(), FMLInjectionData.mccversion); return null; } else if (requiredMCVersion != null) { - FMLRelaunchLog.log(Level.FINE, "The coremod %s requested minecraft version %s and minecraft is %s. It will be loaded.", coreModClass, + FMLRelaunchLog.log(Level.DEBUG, "The coremod %s requested minecraft version %s and minecraft is %s. It will be loaded.", coreModClass, requiredMCVersion.value(), FMLInjectionData.mccversion); } TransformerExclusions trExclusions = coreModClazz.getAnnotation(IFMLLoadingPlugin.TransformerExclusions.class); @@ -420,6 +422,12 @@ public class CoreModManager { int sortIndex = index != null ? index.value() : 0; IFMLLoadingPlugin plugin = (IFMLLoadingPlugin) coreModClazz.newInstance(); + String accessTransformerClass = plugin.getAccessTransformerClass(); + if (accessTransformerClass != null) + { + FMLRelaunchLog.log(Level.DEBUG, "Added access transformer class %s to enqueued access transformers", accessTransformerClass); + accessTransformers.add(accessTransformerClass); + } FMLPluginWrapper wrap = new FMLPluginWrapper(coreModName, plugin, location, sortIndex, dependencies); loadPlugins.add(wrap); FMLRelaunchLog.fine("Enqueued coremod %s", coreModName); @@ -428,21 +436,21 @@ public class CoreModManager { catch (ClassNotFoundException cnfe) { if (!Lists.newArrayList(rootPlugins).contains(coreModClass)) - FMLRelaunchLog.log(Level.SEVERE, cnfe, "Coremod %s: Unable to class load the plugin %s", coreModName, coreModClass); + FMLRelaunchLog.log(Level.ERROR, cnfe, "Coremod %s: Unable to class load the plugin %s", coreModName, coreModClass); else FMLRelaunchLog.fine("Skipping root plugin %s", coreModClass); } catch (ClassCastException cce) { - FMLRelaunchLog.log(Level.SEVERE, cce, "Coremod %s: The plugin %s is not an implementor of IFMLLoadingPlugin", coreModName, coreModClass); + FMLRelaunchLog.log(Level.ERROR, cce, "Coremod %s: The plugin %s is not an implementor of IFMLLoadingPlugin", coreModName, coreModClass); } catch (InstantiationException ie) { - FMLRelaunchLog.log(Level.SEVERE, ie, "Coremod %s: The plugin class %s was not instantiable", coreModName, coreModClass); + FMLRelaunchLog.log(Level.ERROR, ie, "Coremod %s: The plugin class %s was not instantiable", coreModName, coreModClass); } catch (IllegalAccessException iae) { - FMLRelaunchLog.log(Level.SEVERE, iae, "Coremod %s: The plugin class %s was not accessible", coreModName, coreModClass); + FMLRelaunchLog.log(Level.ERROR, iae, "Coremod %s: The plugin class %s was not accessible", coreModName, coreModClass); } return null; } @@ -464,7 +472,7 @@ public class CoreModManager { { if (!pluginMap.containsKey(dep)) { - FMLRelaunchLog.log(Level.SEVERE, "Missing coremod dependency - the coremod %s depends on coremod %s which isn't present.", plug.name, dep); + FMLRelaunchLog.log(Level.ERROR, "Missing coremod dependency - the coremod %s depends on coremod %s which isn't present.", plug.name, dep); throw new RuntimeException(); } sortGraph.addEdge(plug, pluginMap.get(dep)); @@ -477,7 +485,7 @@ public class CoreModManager { } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "There was a problem performing the coremod sort"); + FMLLog.log(Level.ERROR, e, "There was a problem performing the coremod sort"); throw Throwables.propagate(e); } } @@ -552,4 +560,9 @@ public class CoreModManager { } }); } + + public static List getAccessTransformers() + { + return accessTransformers; + } } diff --git a/fml/src/main/java/cpw/mods/fml/relauncher/FMLCorePlugin.java b/fml/src/main/java/cpw/mods/fml/relauncher/FMLCorePlugin.java index 60f860bdc..460bdc1ec 100644 --- a/fml/src/main/java/cpw/mods/fml/relauncher/FMLCorePlugin.java +++ b/fml/src/main/java/cpw/mods/fml/relauncher/FMLCorePlugin.java @@ -22,9 +22,15 @@ public class FMLCorePlugin implements IFMLLoadingPlugin return new String[] { "cpw.mods.fml.common.asm.transformers.MarkerTransformer", "cpw.mods.fml.common.asm.transformers.SideTransformer", + "cpw.mods.fml.common.asm.transformers.EventSubscriptionTransformer", }; } + @Override + public String getAccessTransformerClass() + { + return "cpw.mods.fml.common.asm.transformers.AccessTransformer"; + } @Override public String getModContainerClass() { diff --git a/fml/src/main/java/cpw/mods/fml/relauncher/FMLInjectionData.java b/fml/src/main/java/cpw/mods/fml/relauncher/FMLInjectionData.java index 1dc0bd8d3..558b7da5a 100644 --- a/fml/src/main/java/cpw/mods/fml/relauncher/FMLInjectionData.java +++ b/fml/src/main/java/cpw/mods/fml/relauncher/FMLInjectionData.java @@ -18,7 +18,7 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.List; import java.util.Properties; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import net.minecraft.launchwrapper.LaunchClassLoader; @@ -49,7 +49,7 @@ public class FMLInjectionData } catch (IOException ex) { - FMLRelaunchLog.log(Level.SEVERE, ex, "Could not get FML version information - corrupted installation detected!"); + FMLRelaunchLog.log(Level.ERROR, ex, "Could not get FML version information - corrupted installation detected!"); } } diff --git a/fml/src/main/java/cpw/mods/fml/relauncher/FMLLaunchHandler.java b/fml/src/main/java/cpw/mods/fml/relauncher/FMLLaunchHandler.java index 7b86918d6..b8cd05490 100644 --- a/fml/src/main/java/cpw/mods/fml/relauncher/FMLLaunchHandler.java +++ b/fml/src/main/java/cpw/mods/fml/relauncher/FMLLaunchHandler.java @@ -13,7 +13,7 @@ package cpw.mods.fml.relauncher; import java.io.File; -import java.util.logging.Level; +import org.apache.logging.log4j.Level; import net.minecraft.launchwrapper.LaunchClassLoader; @@ -92,7 +92,7 @@ public class FMLLaunchHandler catch (Throwable t) { t.printStackTrace(); - FMLRelaunchLog.log(Level.SEVERE, t, "An error occurred trying to configure the minecraft home at %s for Forge Mod Loader", minecraftHome.getAbsolutePath()); + FMLRelaunchLog.log(Level.ERROR, t, "An error occurred trying to configure the minecraft home at %s for Forge Mod Loader", minecraftHome.getAbsolutePath()); throw Throwables.propagate(t); } } diff --git a/fml/src/main/java/cpw/mods/fml/relauncher/FMLLogFormatter.java b/fml/src/main/java/cpw/mods/fml/relauncher/FMLLogFormatter.java deleted file mode 100644 index 9e9fd9ead..000000000 --- a/fml/src/main/java/cpw/mods/fml/relauncher/FMLLogFormatter.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Forge Mod Loader - * Copyright (c) 2012-2013 cpw. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Lesser Public License v2.1 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * - * Contributors: - * cpw - implementation - */ - -package cpw.mods.fml.relauncher; - -/** - * Copied from ConsoleLogFormatter for shared use on the client - * - */ -import java.io.PrintWriter; -import java.io.StringWriter; -import java.text.SimpleDateFormat; -import java.util.logging.Formatter; -import java.util.logging.Level; -import java.util.logging.LogRecord; - -final class FMLLogFormatter extends Formatter -{ - static final String LINE_SEPARATOR = System.getProperty("line.separator"); - private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - public String format(LogRecord record) - { - StringBuilder msg = new StringBuilder(); - msg.append(this.dateFormat.format(Long.valueOf(record.getMillis()))); - Level lvl = record.getLevel(); - - String name = lvl.getLocalizedName(); - if ( name == null ) - { - name = lvl.getName(); - } - - if ( ( name != null ) && ( name.length() > 0 ) ) - { - msg.append(" [" + name + "] "); - } - else - { - msg.append(" "); - } - - if (record.getLoggerName() != null) - { - msg.append("["+record.getLoggerName()+"] "); - } - else - { - msg.append("[] "); - } - msg.append(formatMessage(record)); - msg.append(LINE_SEPARATOR); - Throwable thr = record.getThrown(); - - if (thr != null) - { - StringWriter thrDump = new StringWriter(); - thr.printStackTrace(new PrintWriter(thrDump)); - msg.append(thrDump.toString()); - } - - return msg.toString(); - } -} diff --git a/fml/src/main/java/cpw/mods/fml/relauncher/FMLRelaunchLog.java b/fml/src/main/java/cpw/mods/fml/relauncher/FMLRelaunchLog.java index c05e2db1b..6ee69e439 100644 --- a/fml/src/main/java/cpw/mods/fml/relauncher/FMLRelaunchLog.java +++ b/fml/src/main/java/cpw/mods/fml/relauncher/FMLRelaunchLog.java @@ -12,124 +12,15 @@ package cpw.mods.fml.relauncher; -import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.logging.ConsoleHandler; -import java.util.logging.FileHandler; -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.Logger; -import net.minecraft.launchwrapper.LogWrapper; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.spi.LoggerContext; -import com.google.common.base.Throwables; +public class FMLRelaunchLog { -public class FMLRelaunchLog -{ - - private static class ConsoleLogWrapper extends Handler - { - @Override - public void publish(LogRecord record) - { - boolean currInt = Thread.interrupted(); - try - { - ConsoleLogThread.recordQueue.put(record); - } - catch (InterruptedException e) - { - e.printStackTrace(errCache); - } - if (currInt) - { - Thread.currentThread().interrupt(); - } - } - - @Override - public void flush() - { - - } - - @Override - public void close() throws SecurityException - { - } - - } - private static class ConsoleLogThread implements Runnable - { - static ConsoleHandler wrappedHandler = new ConsoleHandler(); - static LinkedBlockingQueue recordQueue = new LinkedBlockingQueue(); - @Override - public void run() - { - do - { - LogRecord lr; - try - { - lr = recordQueue.take(); - wrappedHandler.publish(lr); - } - catch (InterruptedException e) - { - e.printStackTrace(errCache); - Thread.interrupted(); - // Stupid - } - } - while (true); - } - } - private static class LoggingOutStream extends ByteArrayOutputStream - { - private Logger log; - private StringBuilder currentMessage; - - public LoggingOutStream(Logger log) - { - this.log = log; - this.currentMessage = new StringBuilder(); - } - - @Override - public void flush() throws IOException - { - String record; - synchronized(FMLRelaunchLog.class) - { - super.flush(); - record = this.toString(); - super.reset(); - - currentMessage.append(record.replace(FMLLogFormatter.LINE_SEPARATOR, "\n")); - // Are we longer than just the line separator? - int lastIdx = -1; - int idx = currentMessage.indexOf("\n",lastIdx+1); - while (idx >= 0) - { - log.log(Level.INFO, currentMessage.substring(lastIdx+1,idx)); - lastIdx = idx; - idx = currentMessage.indexOf("\n",lastIdx+1); - } - if (lastIdx >= 0) - { - String rem = currentMessage.substring(lastIdx+1); - currentMessage.setLength(0); - currentMessage.append(rem); - } - } - } - } /** * Our special logger for logging issues to. We copy various assets from the * Minecraft logger to achieve a similar appearance. @@ -139,97 +30,25 @@ public class FMLRelaunchLog static File minecraftHome; private static boolean configured; - private static Thread consoleLogThread; - - private static PrintStream errCache; private Logger myLog; - private static FileHandler fileHandler; - - private static FMLLogFormatter formatter; - static String logFileNamePattern; private FMLRelaunchLog() { } + /** * Configure the FML logger */ private static void configureLogging() { - LogManager.getLogManager().reset(); - Logger globalLogger = Logger.getLogger(Logger.GLOBAL_LOGGER_NAME); - globalLogger.setLevel(Level.OFF); - - log.myLog = Logger.getLogger("ForgeModLoader"); - LogWrapper.retarget(log.myLog); - - Logger stdOut = Logger.getLogger("STDOUT"); - stdOut.setParent(log.myLog); - Logger stdErr = Logger.getLogger("STDERR"); - stdErr.setParent(log.myLog); - log.myLog.setLevel(Level.ALL); - log.myLog.setUseParentHandlers(false); - consoleLogThread = new Thread(new ConsoleLogThread()); - consoleLogThread.setDaemon(true); - consoleLogThread.start(); - formatter = new FMLLogFormatter(); - try - { - File logPath = new File(minecraftHome, logFileNamePattern); - fileHandler = new FileHandler(logPath.getPath(), 0, 3) - { - public synchronized void close() throws SecurityException { - // We don't want this handler to reset - } - }; - } - catch (Throwable t) - { - throw Throwables.propagate(t); - } - - resetLoggingHandlers(); - - // Set system out to a log stream - errCache = System.err; - - System.setOut(new PrintStream(new LoggingOutStream(stdOut), true)); - System.setErr(new PrintStream(new LoggingOutStream(stdErr), true)); - - configured = true; - } - private static void resetLoggingHandlers() - { - ConsoleLogThread.wrappedHandler.setLevel(Level.parse(System.getProperty("fml.log.level","INFO"))); - // Console handler captures the normal stderr before it gets replaced - log.myLog.addHandler(new ConsoleLogWrapper()); - ConsoleLogThread.wrappedHandler.setFormatter(formatter); - fileHandler.setLevel(Level.ALL); - fileHandler.setFormatter(formatter); - log.myLog.addHandler(fileHandler); + log.myLog = LogManager.getLogger("FML"); } - public static void loadLogConfiguration(File logConfigFile) + public static void log(String targetLog, Level level, String format, Object... data) { - if (logConfigFile!=null && logConfigFile.exists() && logConfigFile.canRead()) - { - try - { - LogManager.getLogManager().readConfiguration(new FileInputStream(logConfigFile)); - resetLoggingHandlers(); - } - catch (Exception e) - { - log(Level.SEVERE, e, "Error reading logging configuration file %s", logConfigFile.getName()); - } - } - } - public static void log(String logChannel, Level level, String format, Object... data) - { - makeLog(logChannel); - Logger.getLogger(logChannel).log(level, String.format(format, data)); + LogManager.getLogger(targetLog).log(level, String.format(format, data)); } public static void log(Level level, String format, Object... data) @@ -241,10 +60,9 @@ public class FMLRelaunchLog log.myLog.log(level, String.format(format, data)); } - public static void log(String logChannel, Level level, Throwable ex, String format, Object... data) + public static void log(String targetLog, Level level, Throwable ex, String format, Object... data) { - makeLog(logChannel); - Logger.getLogger(logChannel).log(level, String.format(format, data), ex); + LogManager.getLogger(targetLog).log(level, String.format(format, data), ex); } public static void log(Level level, Throwable ex, String format, Object... data) @@ -258,12 +76,12 @@ public class FMLRelaunchLog public static void severe(String format, Object... data) { - log(Level.SEVERE, format, data); + log(Level.ERROR, format, data); } public static void warning(String format, Object... data) { - log(Level.WARNING, format, data); + log(Level.WARN, format, data); } public static void info(String format, Object... data) @@ -273,25 +91,16 @@ public class FMLRelaunchLog public static void fine(String format, Object... data) { - log(Level.FINE, format, data); + log(Level.DEBUG, format, data); } public static void finer(String format, Object... data) { - log(Level.FINER, format, data); + log(Level.TRACE, format, data); } - public static void finest(String format, Object... data) - { - log(Level.FINEST, format, data); - } public Logger getLogger() { return myLog; } - public static void makeLog(String logChannel) - { - Logger l = Logger.getLogger(logChannel); - l.setParent(log.myLog); - } } diff --git a/fml/src/main/java/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java b/fml/src/main/java/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java index 4f81a1737..e83753e62 100644 --- a/fml/src/main/java/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java +++ b/fml/src/main/java/cpw/mods/fml/relauncher/IFMLLoadingPlugin.java @@ -63,6 +63,12 @@ public interface IFMLLoadingPlugin */ void injectData(Map data); + /** + * Return an optional access transformer class for this coremod. It will be injected post-deobf + * so ensure your ATs conform to the new srgnames scheme. + * @return the name of an access transformer class or null if none is provided + */ + String getAccessTransformerClass(); /** * Annotate your load plugin with a list of package prefixes that will *not* be diff --git a/fml/src/main/java/net/minecraft/src/FMLRenderAccessLibrary.java b/fml/src/main/java/net/minecraft/src/FMLRenderAccessLibrary.java index 11d18b38d..581b29f54 100644 --- a/fml/src/main/java/net/minecraft/src/FMLRenderAccessLibrary.java +++ b/fml/src/main/java/net/minecraft/src/FMLRenderAccessLibrary.java @@ -12,8 +12,9 @@ package net.minecraft.src; -import java.util.logging.Level; -import java.util.logging.Logger; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; @@ -32,8 +33,7 @@ public class FMLRenderAccessLibrary { public static Logger getLogger() { - Logger l = Logger.getLogger("FMLRenderAccessLibrary"); - l.setParent(FMLLog.getLogger()); + Logger l = LogManager.getLogger("FMLRenderAccessLibrary"); return l; }