From d9db242f4cf9672d141f1c6c456c6ddc7a6d967f Mon Sep 17 00:00:00 2001 From: LexManos Date: Thu, 24 Jan 2013 03:08:19 -0800 Subject: [PATCH 1/7] Add parameters to FML install to enable/disable certian aspects. Applying patches, running transformer/merger, and decompiling server. --- fml/commands.patch | 33 ++++-------- fml/install/fml.py | 115 ++++++++++++++++++++++++---------------- fml/install/install.bat | 2 +- fml/install/install.py | 35 ++++++++---- 4 files changed, 107 insertions(+), 78 deletions(-) diff --git a/fml/commands.patch b/fml/commands.patch index a833794700..2e3750e843 100644 --- a/fml/commands.patch +++ b/fml/commands.patch @@ -18,18 +18,7 @@ if not os.path.exists(os.path.join(binlk[side], os.path.normpath(testlk[side] + '.class'))): return False return True -@@ -1029,6 +1033,10 @@ - pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver} - pathlog = {CLIENT: self.clientrecomplog, SERVER: self.serverrecomplog} - -+ if side == SERVER: #Disable server because FML recombines it into client -+ self.logger.info('Server side recompiling skipped, this is normal') -+ return -+ - if not os.path.exists(pathbinlk[side]): - os.makedirs(pathbinlk[side]) - -@@ -1062,7 +1070,7 @@ +@@ -1062,7 +1066,7 @@ raise def startserver(self): @@ -38,7 +27,7 @@ classpath = [os.path.join('..', p) for p in classpath] classpath = os.pathsep.join(classpath) os.chdir(self.dirjars) -@@ -1070,7 +1078,7 @@ +@@ -1070,7 +1074,7 @@ self.runmc(forkcmd) def startclient(self): @@ -47,7 +36,7 @@ classpath = [os.path.join('..', p) for p in classpath] classpath = os.pathsep.join(classpath) natives = os.path.join('..', self.dirnatives) -@@ -1197,20 +1205,20 @@ +@@ -1197,20 +1201,20 @@ with open(self.csvmethods, 'rb') as fh: methodsreader = csv.DictReader(fh) for row in methodsreader: @@ -71,7 +60,7 @@ names['params'][row['param']] = row['name'] regexps = { -@@ -1344,13 +1352,13 @@ +@@ -1344,13 +1348,13 @@ methods = {} for row in methodsreader: #HINT: Only include methods that have a non-empty description @@ -87,7 +76,7 @@ fields[row['searge']] = row['desc'].replace('*/', '* /') regexps = { -@@ -1427,7 +1435,7 @@ +@@ -1427,7 +1431,7 @@ self.runcmd(forkcmd) return True @@ -96,7 +85,7 @@ if not reobf: md5lk = {CLIENT: self.md5client, SERVER: self.md5server} else: -@@ -1442,6 +1450,9 @@ +@@ -1442,6 +1446,9 @@ class_path = '' else: class_path += '/' @@ -106,7 +95,7 @@ for class_file in fnmatch.filter(filelist, '*.class'): class_name = class_path + os.path.splitext(class_file)[0] bin_file = os.path.normpath(os.path.join(path, class_file)) -@@ -1535,6 +1546,8 @@ +@@ -1535,6 +1542,8 @@ if not os.path.exists(outpathlk[side]): os.makedirs(outpathlk[side]) @@ -115,7 +104,7 @@ # HINT: We extract the modified class files with closing(zipfile.ZipFile(jarlk[side])) as zipjar: for in_class in trgclasses: -@@ -1548,6 +1561,23 @@ +@@ -1548,6 +1557,23 @@ out_class = out_class.replace(self.nullpkg, '') if out_class[0] == '/': out_class = out_class[1:] @@ -139,7 +128,7 @@ try: zipjar.extract(out_class, outpathlk[side]) self.logger.info('> Outputted %s to %s as %s', in_class.ljust(35), outpathlk[side], out_class) -@@ -1594,6 +1624,9 @@ +@@ -1594,6 +1620,9 @@ sys.exit(1) for entry in newfiles: @@ -149,7 +138,7 @@ if entry[3] == 'U': self.logger.info('Retrieving file from server : %s', entry[0]) cur_file = os.path.normpath(entry[0]) -@@ -1614,6 +1647,9 @@ +@@ -1614,6 +1643,9 @@ md5reoblk = {CLIENT: self.md5reobfclient, SERVER: self.md5reobfserver} outpathlk = {CLIENT: self.srcmodclient, SERVER: self.srcmodserver} src = {CLIENT: self.srcclient, SERVER: self.srcserver} @@ -159,7 +148,7 @@ # HINT: We need a table for the old md5 and the new ones md5table = {} -@@ -1656,3 +1692,6 @@ +@@ -1656,3 +1688,6 @@ except IOError: self.logger.error('* File %s copy failed', in_class) diff --git a/fml/install/fml.py b/fml/install/fml.py index de4d31821b..419beea7ea 100644 --- a/fml/install/fml.py +++ b/fml/install/fml.py @@ -219,7 +219,9 @@ def cleanup_source(path): src_file = os.path.normpath(os.path.join(path, cur_file)) updatefile(src_file) -def setup_fml(fml_dir, mcp_dir): +compile_tools = True +def setup_fml(fml_dir, mcp_dir, disable_at=False, disable_merge=False, enable_server=False, disable_client=False): + global compile_tools sys.path.append(mcp_dir) from runtime.decompile import decompile from runtime.cleanup import cleanup @@ -241,7 +243,10 @@ def setup_fml(fml_dir, mcp_dir): if not download_deps(mcp_dir): sys.exit(1) + compile_tools = True + def applyrg_shunt(self, side, reobf=False, applyrg_real = Commands.applyrg): + global compile_tools if not self.has_wine and not self.has_astyle: self.logger.error('!! Please install either wine or astyle for source cleanup !!') self.logger.error('!! This is REQUIRED by FML/Forge Cannot proceed !!') @@ -258,7 +263,7 @@ def setup_fml(fml_dir, mcp_dir): cmd_compile = '"%s" -Xlint:-options -deprecation -g -source 1.6 -target 1.6 -classpath "{classpath}" -sourcepath "{sourcepath}" -d "{outpath}" "{target}"' % self.cmdjavac cmd_compile = cmd_compile.format(classpath=class_path, sourcepath=dir_common, outpath=dir_bin, target="{target}") - if (side == CLIENT): + if compile_tools: self.logger.info('> Compiling AccessTransformer') if not runcmd(self, cmd_compile.format(target=os.path.join(dir_trans, 'AccessTransformer.java')), echo=False): sys.exit(1) @@ -266,32 +271,41 @@ def setup_fml(fml_dir, mcp_dir): self.logger.info('> Compiling MCPMerger') if not runcmd(self, cmd_compile.format(target=os.path.join(dir_trans, 'MCPMerger.java')), echo=False): sys.exit(1) - - self.logger.info('> Running MCPMerger') - forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.MCPMerger "{mergecfg}" "{client}" "{server}"' % self.cmdjava).format( - classpath=class_path, mergecfg=os.path.join(fml_dir, 'mcp_merge.cfg'), client=jars[CLIENT], server=jars[SERVER]) + compile_tools = False + + if side == CLIENT: + if not disable_merge: + self.logger.info('> Running MCPMerger') + forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.MCPMerger "{mergecfg}" "{client}" "{server}"' % self.cmdjava).format( + classpath=class_path, mergecfg=os.path.join(fml_dir, 'mcp_merge.cfg'), client=jars[CLIENT], server=jars[SERVER]) + + if not runcmd(self, forkcmd): + sys.exit(1) + else: + self.logger.info('> MCPMerge disabled') + + if not disable_at: + self.logger.info('> Running AccessTransformer') + forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.AccessTransformer "{jar}" "{fmlconfig}"' % self.cmdjava).format( + classpath=class_path, jar=jars[side], fmlconfig=os.path.join(fml_dir, 'common', 'fml_at.cfg')) + + forge_cfg = os.path.join(fml_dir, '..', 'common', 'forge_at.cfg') + if os.path.isfile(forge_cfg): + self.logger.info(' Forge config detected') + forkcmd += ' "%s"' % forge_cfg + + for dirname, dirnames, filenames in os.walk(os.path.join(fml_dir, '..', 'accesstransformers')): + for filename in filenames: + accesstransformer = os.path.join(dirname, filename) + if os.path.isfile(accesstransformer): + self.logger.info(' Access Transformer "%s" detected' % filename) + forkcmd += ' "%s"' % accesstransformer + if not runcmd(self, forkcmd): sys.exit(1) - - self.logger.info('> Running AccessTransformer') - forkcmd = ('"%s" -classpath "{classpath}" cpw.mods.fml.common.asm.transformers.AccessTransformer "{jar}" "{fmlconfig}"' % self.cmdjava).format( - classpath=class_path, jar=jars[side], fmlconfig=os.path.join(fml_dir, 'common', 'fml_at.cfg')) - - forge_cfg = os.path.join(fml_dir, '..', 'common', 'forge_at.cfg') - if os.path.isfile(forge_cfg): - self.logger.info(' Forge config detected') - forkcmd += ' "%s"' % forge_cfg - - for dirname, dirnames, filenames in os.walk(os.path.join(fml_dir, '..', 'accesstransformers')): - for filename in filenames: - accesstransformer = os.path.join(dirname, filename) - if os.path.isfile(accesstransformer): - self.logger.info(' Access Transformer "%s" detected' % filename) - forkcmd += ' "%s"' % accesstransformer - - if not runcmd(self, forkcmd): - sys.exit(1) + else: + self.logger.info('> Access Transformer disabled') self.logger.info('> Really Applying Retroguard') applyrg_real(self, side, reobf) @@ -314,8 +328,8 @@ def setup_fml(fml_dir, mcp_dir): Commands.applyrg = applyrg_shunt Commands.checkjars = checkjars_shunt #decompile -d -n -r - # Conf JAD CSV -r -d -a -n -p -o -l -g -c -s - decompile(None, False, False, True, True, False, True, False, False, False, False, True, False) + # Conf JAD CSV -r -d -a -n -p -o -l -g -c -s + decompile(None, False, False, True, True, False, True, False, False, False, False, not disable_client, enable_server) reset_logger() os.chdir(fml_dir) @@ -334,8 +348,14 @@ def setup_fml(fml_dir, mcp_dir): os.chdir(mcp_dir) commands = Commands(verify=True) - updatemd5_side(mcp_dir, commands, CLIENT) - reset_logger() + + if not disable_client: + updatemd5_side(mcp_dir, commands, CLIENT) + reset_logger() + + if enable_server: + updatemd5_side(mcp_dir, commands, CLIENT) + reset_logger() os.chdir(fml_dir) @@ -409,16 +429,16 @@ def apply_fml_patches(fml_dir, mcp_dir, src_dir, copy_files=True): if os.path.isdir(os.path.join(src_dir, 'minecraft', 'argo')): shutil.rmtree(os.path.join(src_dir, 'minecraft', 'argo')) -def finish_setup_fml(fml_dir, mcp_dir): +def finish_setup_fml(fml_dir, mcp_dir, enable_server=False, disable_client=False): sys.path.append(mcp_dir) from runtime.updatenames import updatenames from runtime.updatemd5 import updatemd5 from runtime.updatemcp import updatemcp os.chdir(mcp_dir) - updatenames(None, True, True, False) + updatenames(None, True, not disable_client, enable_server) reset_logger() - updatemd5(None, True, True, False) + updatemd5(None, True, not disable_client, enable_server) reset_logger() os.chdir(fml_dir) @@ -940,18 +960,21 @@ def gen_renamed_conf(mcp_dir, fml_dir): cls = repackage_class(pkgs, cls) outf.write('%s.%s%s=%s\n' % (cls, func, sig, named)) - print 'Creating re-packaged MCP patch' - patch_in = os.path.join(mcp_dir, 'conf', 'patches', 'minecraft_ff.patch') - patch_tmp = os.path.join(mcp_dir, 'conf', 'patches', 'minecraft_ff.patch.tmp') + print 'Creating re-packaged MCP patches' - regnms = re.compile(r'net\\minecraft\\src\\(\w+)') - with open(patch_in, 'r') as fh: - buf = fh.read() - def mapname(match): - return repackage_class(pkgs, match.group(0).replace('\\', '/')).replace('/', '\\') - buf = regnms.sub(mapname, buf) - - with open(patch_tmp, 'w') as fh: - fh.write(buf) - - shutil.move(patch_tmp, patch_in) + def fix_patches(patch_in, patch_tmp): + regnms = re.compile(r'net\\minecraft\\src\\(\w+)') + with open(patch_in, 'r') as fh: + buf = fh.read() + def mapname(match): + return repackage_class(pkgs, match.group(0).replace('\\', '/')).replace('/', '\\') + buf = regnms.sub(mapname, buf) + + with open(patch_tmp, 'w') as fh: + fh.write(buf) + + shutil.move(patch_tmp, patch_in) + + patch_dir = os.path.join(mcp_dir, 'conf', 'patches') + fix_patches(os.path.join(patch_dir, 'minecraft_ff.patch' ), os.path.join(patch_dir, 'tmp.patch')) + fix_patches(os.path.join(patch_dir, 'minecraft_server_ff.patch'), os.path.join(patch_dir, 'tmp.patch')) \ No newline at end of file diff --git a/fml/install/install.bat b/fml/install/install.bat index 4698e2b229..b31f477296 100644 --- a/fml/install/install.bat +++ b/fml/install/install.bat @@ -1,4 +1,4 @@ echo off @set PATH=%PATH%;%SystemDir%\system32;%SystemRoot%\System32;.\python\ -python_fml install.py +python_fml install.py %* pause diff --git a/fml/install/install.py b/fml/install/install.py index 5971c78af0..97dec17703 100644 --- a/fml/install/install.py +++ b/fml/install/install.py @@ -3,24 +3,41 @@ from optparse import OptionParser from fml import setup_fml, finish_setup_fml, apply_fml_patches, setup_mcp -def fml_main(fml_dir, mcp_dir, dont_gen_conf=True): +def fml_main(fml_dir, mcp_dir, dont_gen_conf=True, disable_patches=False, disable_at=False, disable_merge=False, enable_server=False, disable_client=False): print '================ Forge ModLoader Setup Start ===================' setup_mcp(fml_dir, mcp_dir, dont_gen_conf) - setup_fml(fml_dir, mcp_dir) - apply_fml_patches(fml_dir, mcp_dir, os.path.join(mcp_dir, 'src')) - finish_setup_fml(fml_dir, mcp_dir) + setup_fml(fml_dir, mcp_dir, disable_at=disable_at, disable_merge=disable_merge, enable_server=enable_server, disable_client=disable_client) + if disable_patches: + print 'Patching disabled' + else: + apply_fml_patches(fml_dir, mcp_dir, os.path.join(mcp_dir, 'src')) + finish_setup_fml(fml_dir, mcp_dir, enable_server=enable_server, disable_client=disable_client) print '================ Forge ModLoader Setup End ===================' if __name__ == '__main__': parser = OptionParser() - parser.add_option('-m', '--mcp-dir', action='store_true', dest='mcp_dir', help='Path to download/extract MCP to', default=None) + parser.add_option('-m', '--mcp-dir', action='store_true', dest='mcp_dir', help='Path to download/extract MCP to', default=None ) + parser.add_option('-p', '--no-patch', action="store_true", dest='no_patch', help='Disable application of FML patches', default=False) + parser.add_option('-a', '--no-access', action="store_true", dest='no_access', help='Disable access transformers', default=False) + parser.add_option('-s', '--server', action="store_true", dest='enable_server', help='Enable decompilation of server', default=False) + parser.add_option('-c', '--no-client', action="store_true", dest='no_client', help='Disable decompilation of server', default=False) + parser.add_option('-e', '--no-merge', action="store_true", dest='no_merge', help='Disable merging server code into client', default=False) options, _ = parser.parse_args() fml_dir = os.path.dirname(os.path.abspath(__file__)) + mcp_dir = os.path.abspath('mcp') if not options.mcp_dir is None: - fml_main(fml_dir, os.path.abspath(options.mcp_dir)) + mcp_dir = os.path.abspath(options.mcp_dir) elif os.path.isfile(os.path.join('..', 'runtime', 'commands.py')): - fml_main(fml_dir, os.path.abspath('..')) - else: - fml_main(fml_dir, os.path.abspath('mcp')) \ No newline at end of file + mcp_dir = os.path.abspath('..') + + if options.no_client: + options.no_patch = True + + if options.no_merge: + options.no_patch = True + + fml_main(fml_dir, mcp_dir, disable_patches=options.no_patch, + disable_at=options.no_access, disable_merge=options.no_merge, + enable_server=options.enable_server, disable_client=options.no_client) \ No newline at end of file From 3dbffd17541f6f6a5b410ba78d6fd5739543ce18 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 24 Jan 2013 10:23:36 -0500 Subject: [PATCH 2/7] Tweak a method signature --- fml/common/cpw/mods/fml/common/Loader.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index e212775a07..ba00126ee1 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -27,7 +27,6 @@ import java.util.concurrent.Callable; import java.util.logging.Level; import net.minecraft.crash.CallableMinecraftVersion; -import net.minecraft.server.MinecraftServer; import com.google.common.base.CharMatcher; import com.google.common.base.Function; @@ -762,7 +761,7 @@ public class Loader modController.transition(LoaderState.AVAILABLE); } - public boolean serverAboutToStart(MinecraftServer server) + public boolean serverAboutToStart(Object server) { try { From c19646421a4ea327f29388cedf652af7d088ae71 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 24 Jan 2013 17:29:46 -0500 Subject: [PATCH 3/7] Deprecate the old GUI ticktype. They're dead and have been for some time. --- fml/common/cpw/mods/fml/common/TickType.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fml/common/cpw/mods/fml/common/TickType.java b/fml/common/cpw/mods/fml/common/TickType.java index 30a00f8189..3e7426cd31 100644 --- a/fml/common/cpw/mods/fml/common/TickType.java +++ b/fml/common/cpw/mods/fml/common/TickType.java @@ -31,17 +31,14 @@ public enum TickType { */ RENDER, /** - * client side - * Fired during the render processing phase if a GUI is open - * arg 0 : float "partial render time" - * arg 1 : the open gui or null if no gui is open + * Not fired */ + @Deprecated GUI, /** - * client side - * Fired during the client evaluation loop - * arg 0 : The open gui or null if no gui is open + * Not fired */ + @Deprecated CLIENTGUI, /** * server side From 5c99e3488afc2c47c04f51dee14d4569d4c4b3b3 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 27 Jan 2013 15:54:36 -0500 Subject: [PATCH 4/7] Try and handle "death on startup" a bit cleaner --- fml/common/cpw/mods/fml/common/FMLCommonHandler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index 2fc57b7a58..eb13499af8 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -451,6 +451,10 @@ public class FMLCommonHandler public boolean shouldServerBeKilledQuietly() { + if (sidedDelegate == null) + { + return false; + } return sidedDelegate.shouldServerShouldBeKilledQuietly(); } From 0c6019da8f4f551801f9438c48d51bd10a127fa7 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 30 Jan 2013 18:57:21 -0500 Subject: [PATCH 5/7] A log of logging cleanup. FML will now read logging.properties to configure logging channels a couple of times during startup. You should be able to filter a lot of messages based on things like modid and certain FML related features that can be noisy like item tracking. Should close #175 --- .../cpw/mods/fml/client/SpriteHelper.java | 6 +- .../cpw/mods/fml/client/TextureFXManager.java | 13 ++-- .../modloader/ModLoaderClientHelper.java | 16 ++--- .../minecraft/src/FMLRenderAccessLibrary.java | 6 +- fml/commands.patch | 33 ++++++--- .../cpw/mods/fml/common/FMLCommonHandler.java | 7 +- .../mods/fml/common/FMLDummyContainer.java | 5 +- fml/common/cpw/mods/fml/common/FMLLog.java | 15 ++++ .../cpw/mods/fml/common/FMLModContainer.java | 26 +++---- .../cpw/mods/fml/common/LoadController.java | 32 ++++++--- fml/common/cpw/mods/fml/common/Loader.java | 40 +++++++---- .../cpw/mods/fml/common/ModClassLoader.java | 2 +- .../fml/common/discovery/ModDiscoverer.java | 2 +- .../event/FMLPreInitializationEvent.java | 2 + .../mods/fml/common/registry/GameData.java | 18 ++--- .../fml/common/registry/LanguageRegistry.java | 6 +- .../mods/fml/relauncher/FMLRelaunchLog.java | 72 +++++++++++++++---- 17 files changed, 203 insertions(+), 98 deletions(-) diff --git a/fml/client/cpw/mods/fml/client/SpriteHelper.java b/fml/client/cpw/mods/fml/client/SpriteHelper.java index e65439e6a4..0c2a6133f2 100644 --- a/fml/client/cpw/mods/fml/client/SpriteHelper.java +++ b/fml/client/cpw/mods/fml/client/SpriteHelper.java @@ -80,7 +80,7 @@ public class SpriteHelper initMCSpriteMaps(); } if (spriteInfo.containsKey(file)) { - FMLCommonHandler.instance().getFMLLogger().finer(String.format("Duplicate attempt to register a sprite file %s for overriding -- ignoring",file)); + FMLLog.log("fml.TextureManager", Level.FINE, "Duplicate attempt to register a sprite file %s for overriding -- ignoring",file); return; } spriteInfo.put(file, toBitSet(spriteMap)); @@ -98,7 +98,7 @@ public class SpriteHelper if (slots == null) { Exception ex = new Exception(String.format("Invalid getUniqueSpriteIndex call for texture: %s", path)); - FMLLog.log(Level.SEVERE, ex, "A critical error has been detected with sprite overrides"); + FMLLog.log("fml.TextureManager", Level.SEVERE, ex, "A critical error has been detected with sprite overrides"); FMLCommonHandler.instance().raiseException(ex,"Invalid request to getUniqueSpriteIndex",true); } @@ -107,7 +107,7 @@ public class SpriteHelper if (ret == -1) { Exception ex = new Exception(String.format("No more sprite indicies left for: %s", path)); - FMLLog.log(Level.SEVERE, ex, "There are no sprite indicies left for %s", path); + FMLLog.log("fml.TextureManager", Level.SEVERE, ex, "There are no sprite indicies left for %s", path); FMLCommonHandler.instance().raiseException(ex,"No more sprite indicies left", true); } return ret; diff --git a/fml/client/cpw/mods/fml/client/TextureFXManager.java b/fml/client/cpw/mods/fml/client/TextureFXManager.java index d041348aee..fe1fe5575f 100644 --- a/fml/client/cpw/mods/fml/client/TextureFXManager.java +++ b/fml/client/cpw/mods/fml/client/TextureFXManager.java @@ -15,6 +15,7 @@ import java.util.IdentityHashMap; import java.util.List; import java.util.ListIterator; import java.util.Map; +import java.util.logging.Level; import javax.imageio.ImageIO; @@ -77,7 +78,7 @@ public class TextureFXManager } catch (Exception e) { - FMLLog.warning("Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to", name); + FMLLog.log("fml.TextureManager", Level.WARNING, "Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to", name); if (ifx != null) { ifx.setErrored(true); @@ -93,7 +94,7 @@ public class TextureFXManager int target = ((dim.width >> 4) * (dim.height >> 4)) << 2; if (effect.field_76852_a.length != target) { - FMLLog.warning("Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_76852_a.length, target); + FMLLog.log("fml.TextureManager", Level.WARNING, "Detected a texture FX sizing discrepancy in %s (%d, %d)", name, effect.field_76852_a.length, target); ifx.setErrored(true); return false; } @@ -232,7 +233,7 @@ public class TextureFXManager for (OverrideInfo animationOverride : animationSet) { renderer.func_78355_a(animationOverride.textureFX); addedTextureFX.add(animationOverride.textureFX); - FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", animationOverride.index, animationOverride.textureFX.field_76850_b, animationOverride.textureFX.getClass().getSimpleName(), animationOverride.textureFX.field_76847_f)); + FMLLog.log("fml.TextureManager", Level.FINE, "Registered texture override %d (%d) on %s (%d)", animationOverride.index, animationOverride.textureFX.field_76850_b, animationOverride.textureFX.getClass().getSimpleName(), animationOverride.textureFX.field_76847_f); } for (String fileToOverride : overrideInfo.keySet()) { @@ -243,11 +244,11 @@ public class TextureFXManager ModTextureStatic mts=new ModTextureStatic(override.index, 1, override.texture, image); renderer.func_78355_a(mts); addedTextureFX.add(mts); - FMLCommonHandler.instance().getFMLLogger().finer(String.format("Registered texture override %d (%d) on %s (%d)", override.index, mts.field_76850_b, override.texture, mts.field_76847_f)); + FMLLog.log("fml.TextureManager", Level.FINE, "Registered texture override %d (%d) on %s (%d)", override.index, mts.field_76850_b, override.texture, mts.field_76847_f); } catch (IOException e) { - FMLCommonHandler.instance().getFMLLogger().throwing("FMLClientHandler", "registerTextureOverrides", e); + FMLLog.log("fml.TextureManager", Level.WARNING, e, "Exception occurred registering texture override for %s", fileToOverride); } } } @@ -294,7 +295,7 @@ public class TextureFXManager info.override = overridingTexturePath; info.texture = textureToOverride; overrideInfo.put(textureToOverride, info); - FMLLog.fine("Overriding %s @ %d with %s. %d slots remaining",textureToOverride, location, overridingTexturePath, SpriteHelper.freeSlotCount(textureToOverride)); + FMLLog.log("fml.TextureManager", Level.FINE, "Overriding %s @ %d with %s. %d slots remaining",textureToOverride, location, overridingTexturePath, SpriteHelper.freeSlotCount(textureToOverride)); } public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine, String path) throws IOException diff --git a/fml/client/cpw/mods/fml/client/modloader/ModLoaderClientHelper.java b/fml/client/cpw/mods/fml/client/modloader/ModLoaderClientHelper.java index 6312484b72..4d3016653c 100644 --- a/fml/client/cpw/mods/fml/client/modloader/ModLoaderClientHelper.java +++ b/fml/client/cpw/mods/fml/client/modloader/ModLoaderClientHelper.java @@ -57,38 +57,38 @@ public class ModLoaderClientHelper implements IModLoaderSidedHelper public static void handleFinishLoadingFor(ModLoaderModContainer mc, Minecraft game) { - FMLLog.finer("Handling post startup activities for ModLoader mod %s", mc.getModId()); + FMLLog.log(mc.getModId(), Level.FINE, "Handling post startup activities for ModLoader mod %s", mc.getModId()); BaseMod mod = (BaseMod) mc.getMod(); Map, Render> renderers = Maps.newHashMap(RenderManager.field_78727_a.field_78729_o); try { - FMLLog.finest("Requesting renderers from basemod %s", mc.getModId()); + FMLLog.log(mc.getModId(), Level.FINEST, "Requesting renderers from basemod %s", mc.getModId()); mod.addRenderer(renderers); - FMLLog.finest("Received %d renderers from basemod %s", renderers.size(), mc.getModId()); + FMLLog.log(mc.getModId(), Level.FINEST, "Received %d renderers from basemod %s", renderers.size(), mc.getModId()); } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "A severe problem was detected with the mod %s during the addRenderer call. Continuing, but expect odd results", mc.getModId()); + FMLLog.log(mc.getModId(), Level.SEVERE, e, "A severe problem was detected with the mod %s during the addRenderer call. Continuing, but expect odd results", mc.getModId()); } MapDifference, Render> difference = Maps.difference(RenderManager.field_78727_a.field_78729_o, renderers, Equivalences.identity()); for ( Entry, Render> e : difference.entriesOnlyOnLeft().entrySet()) { - FMLLog.warning("The mod %s attempted to remove an entity renderer %s from the entity map. This will be ignored.", mc.getModId(), e.getKey().getName()); + FMLLog.log(mc.getModId(), Level.WARNING, "The mod %s attempted to remove an entity renderer %s from the entity map. This will be ignored.", mc.getModId(), e.getKey().getName()); } for (Entry, Render> e : difference.entriesOnlyOnRight().entrySet()) { - FMLLog.finest("Registering ModLoader entity renderer %s as instance of %s", e.getKey().getName(), e.getValue().getClass().getName()); + FMLLog.log(mc.getModId(), Level.FINEST, "Registering ModLoader entity renderer %s as instance of %s", e.getKey().getName(), e.getValue().getClass().getName()); RenderingRegistry.registerEntityRenderingHandler(e.getKey(), e.getValue()); } for (Entry, ValueDifference> e : difference.entriesDiffering().entrySet()) { - FMLLog.finest("Registering ModLoader entity rendering override for %s as instance of %s", e.getKey().getName(), e.getValue().rightValue().getClass().getName()); + FMLLog.log(mc.getModId(), Level.FINEST, "Registering ModLoader entity rendering override for %s as instance of %s", e.getKey().getName(), e.getValue().rightValue().getClass().getName()); RenderingRegistry.registerEntityRenderingHandler(e.getKey(), e.getValue().rightValue()); } @@ -98,7 +98,7 @@ public class ModLoaderClientHelper implements IModLoaderSidedHelper } catch (Exception e) { - FMLLog.log(Level.SEVERE, e, "A severe problem was detected with the mod %s during the registerAnimation call. Continuing, but expect odd results", mc.getModId()); + FMLLog.log(mc.getModId(), Level.SEVERE, e, "A severe problem was detected with the mod %s during the registerAnimation call. Continuing, but expect odd results", mc.getModId()); } } diff --git a/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java b/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java index 2032e8aed3..18d7159678 100644 --- a/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java +++ b/fml/client/net/minecraft/src/FMLRenderAccessLibrary.java @@ -41,12 +41,14 @@ public class FMLRenderAccessLibrary { public static Logger getLogger() { - return FMLLog.getLogger(); + Logger l = Logger.getLogger("FMLRenderAccessLibrary"); + l.setParent(FMLLog.getLogger()); + return l; } public static void log(Level level, String message) { - FMLLog.log(level, message); + FMLLog.log("FMLRenderAccessLibrary", level, message); } public static void log(Level level, String message, Throwable throwable) diff --git a/fml/commands.patch b/fml/commands.patch index 2e3750e843..a833794700 100644 --- a/fml/commands.patch +++ b/fml/commands.patch @@ -18,7 +18,18 @@ if not os.path.exists(os.path.join(binlk[side], os.path.normpath(testlk[side] + '.class'))): return False return True -@@ -1062,7 +1066,7 @@ +@@ -1029,6 +1033,10 @@ + pathsrclk = {CLIENT: self.srcclient, SERVER: self.srcserver} + pathlog = {CLIENT: self.clientrecomplog, SERVER: self.serverrecomplog} + ++ if side == SERVER: #Disable server because FML recombines it into client ++ self.logger.info('Server side recompiling skipped, this is normal') ++ return ++ + if not os.path.exists(pathbinlk[side]): + os.makedirs(pathbinlk[side]) + +@@ -1062,7 +1070,7 @@ raise def startserver(self): @@ -27,7 +38,7 @@ classpath = [os.path.join('..', p) for p in classpath] classpath = os.pathsep.join(classpath) os.chdir(self.dirjars) -@@ -1070,7 +1074,7 @@ +@@ -1070,7 +1078,7 @@ self.runmc(forkcmd) def startclient(self): @@ -36,7 +47,7 @@ classpath = [os.path.join('..', p) for p in classpath] classpath = os.pathsep.join(classpath) natives = os.path.join('..', self.dirnatives) -@@ -1197,20 +1201,20 @@ +@@ -1197,20 +1205,20 @@ with open(self.csvmethods, 'rb') as fh: methodsreader = csv.DictReader(fh) for row in methodsreader: @@ -60,7 +71,7 @@ names['params'][row['param']] = row['name'] regexps = { -@@ -1344,13 +1348,13 @@ +@@ -1344,13 +1352,13 @@ methods = {} for row in methodsreader: #HINT: Only include methods that have a non-empty description @@ -76,7 +87,7 @@ fields[row['searge']] = row['desc'].replace('*/', '* /') regexps = { -@@ -1427,7 +1431,7 @@ +@@ -1427,7 +1435,7 @@ self.runcmd(forkcmd) return True @@ -85,7 +96,7 @@ if not reobf: md5lk = {CLIENT: self.md5client, SERVER: self.md5server} else: -@@ -1442,6 +1446,9 @@ +@@ -1442,6 +1450,9 @@ class_path = '' else: class_path += '/' @@ -95,7 +106,7 @@ for class_file in fnmatch.filter(filelist, '*.class'): class_name = class_path + os.path.splitext(class_file)[0] bin_file = os.path.normpath(os.path.join(path, class_file)) -@@ -1535,6 +1542,8 @@ +@@ -1535,6 +1546,8 @@ if not os.path.exists(outpathlk[side]): os.makedirs(outpathlk[side]) @@ -104,7 +115,7 @@ # HINT: We extract the modified class files with closing(zipfile.ZipFile(jarlk[side])) as zipjar: for in_class in trgclasses: -@@ -1548,6 +1557,23 @@ +@@ -1548,6 +1561,23 @@ out_class = out_class.replace(self.nullpkg, '') if out_class[0] == '/': out_class = out_class[1:] @@ -128,7 +139,7 @@ try: zipjar.extract(out_class, outpathlk[side]) self.logger.info('> Outputted %s to %s as %s', in_class.ljust(35), outpathlk[side], out_class) -@@ -1594,6 +1620,9 @@ +@@ -1594,6 +1624,9 @@ sys.exit(1) for entry in newfiles: @@ -138,7 +149,7 @@ if entry[3] == 'U': self.logger.info('Retrieving file from server : %s', entry[0]) cur_file = os.path.normpath(entry[0]) -@@ -1614,6 +1643,9 @@ +@@ -1614,6 +1647,9 @@ md5reoblk = {CLIENT: self.md5reobfclient, SERVER: self.md5reobfserver} outpathlk = {CLIENT: self.srcmodclient, SERVER: self.srcmodserver} src = {CLIENT: self.srcclient, SERVER: self.srcserver} @@ -148,7 +159,7 @@ # HINT: We need a table for the old md5 and the new ones md5table = {} -@@ -1656,3 +1688,6 @@ +@@ -1656,3 +1692,6 @@ except IOError: self.logger.error('* File %s copy failed', in_class) diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index eb13499af8..43e6715c7e 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.logging.Level; import java.util.logging.Logger; import net.minecraft.crash.CrashReport; @@ -92,10 +93,10 @@ public class FMLCommonHandler public void beginLoading(IFMLSidedHandler handler) { sidedDelegate = handler; - FMLLog.info("Attempting early MinecraftForge initialization"); + FMLLog.log("MinecraftForge", Level.INFO, "Attempting early MinecraftForge initialization"); callForgeMethod("initialize"); callForgeMethod("registerCrashCallable"); - FMLLog.info("Completed early MinecraftForge initialization"); + FMLLog.log("MinecraftForge", Level.INFO, "Completed early MinecraftForge initialization"); } public void rescheduleTicks(Side side) @@ -189,7 +190,7 @@ public class FMLCommonHandler */ public void raiseException(Throwable exception, String message, boolean stopGame) { - FMLCommonHandler.instance().getFMLLogger().throwing("FMLHandler", "raiseException", exception); + FMLLog.log(Level.SEVERE, exception, "Something raised an exception. The message was '%s'. 'stopGame' is %b", message, stopGame); if (stopGame) { getSidedDelegate().haltGame(message,exception); diff --git a/fml/common/cpw/mods/fml/common/FMLDummyContainer.java b/fml/common/cpw/mods/fml/common/FMLDummyContainer.java index 37edd2ce69..d9048d1e65 100644 --- a/fml/common/cpw/mods/fml/common/FMLDummyContainer.java +++ b/fml/common/cpw/mods/fml/common/FMLDummyContainer.java @@ -18,6 +18,7 @@ import java.security.cert.Certificate; import java.util.Arrays; import java.util.Map; import java.util.Set; +import java.util.logging.Level; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; @@ -96,12 +97,12 @@ public class FMLDummyContainer extends DummyModContainer implements WorldAccessC ModContainer container = Loader.instance().getIndexedModList().get(modId); if (container == null) { - FMLLog.severe("This world was saved with mod %s which appears to be missing, things may not work well", modId); + FMLLog.log("fml.ModTracker", Level.SEVERE, "This world was saved with mod %s which appears to be missing, things may not work well", modId); continue; } if (!modVersion.equals(container.getVersion())) { - FMLLog.info("This world was saved with mod %s version %s and it is now at version %s, things may not work well", modId, modVersion, container.getVersion()); + FMLLog.log("fml.ModTracker", Level.INFO, "This world was saved with mod %s version %s and it is now at version %s, things may not work well", modId, modVersion, container.getVersion()); } } } diff --git a/fml/common/cpw/mods/fml/common/FMLLog.java b/fml/common/cpw/mods/fml/common/FMLLog.java index f9e6d676df..cf8dba8c58 100644 --- a/fml/common/cpw/mods/fml/common/FMLLog.java +++ b/fml/common/cpw/mods/fml/common/FMLLog.java @@ -7,11 +7,21 @@ 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) + { + coreLog.log(logChannel, level, format, data); + } + public static void log(Level level, String format, Object... data) { coreLog.log(level, format, data); } + public static void log(String logChannel, Level level, Throwable ex, String format, Object... data) + { + coreLog.log(logChannel, level, ex, format, data); + } + public static void log(Level level, Throwable ex, String format, Object... data) { coreLog.log(level, ex, format, data); @@ -50,4 +60,9 @@ public class FMLLog { return coreLog.getLogger(); } + + public static void makeLog(String logChannel) + { + coreLog.makeLog(logChannel); + } } diff --git a/fml/common/cpw/mods/fml/common/FMLModContainer.java b/fml/common/cpw/mods/fml/common/FMLModContainer.java index 252aea20c5..7fe9565c4d 100644 --- a/fml/common/cpw/mods/fml/common/FMLModContainer.java +++ b/fml/common/cpw/mods/fml/common/FMLModContainer.java @@ -164,15 +164,15 @@ public class FMLModContainer implements ModContainer modMetadata.requiredMods = requirements; modMetadata.dependencies = dependencies; modMetadata.dependants = dependants; - FMLLog.finest("Parsed dependency info : %s %s %s", requirements, dependencies, dependants); + FMLLog.log(getModId(), Level.FINEST, "Parsed dependency info : %s %s %s", requirements, dependencies, dependants); } else { - FMLLog.finest("Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants); + FMLLog.log(getModId(), Level.FINEST, "Using mcmod dependency info : %s %s %s", modMetadata.requiredMods, modMetadata.dependencies, modMetadata.dependants); } if (Strings.isNullOrEmpty(modMetadata.name)) { - FMLLog.info("Mod %s is missing the required element 'name'. Substituting %s", getModId(), getModId()); + FMLLog.log(getModId(), Level.INFO,"Mod %s is missing the required element 'name'. Substituting %s", getModId(), getModId()); modMetadata.name = getModId(); } internalVersion = (String) descriptor.get("version"); @@ -182,18 +182,18 @@ public class FMLModContainer implements ModContainer if (versionProps != null) { internalVersion = versionProps.getProperty(getModId()+".version"); - FMLLog.fine("Found version %s for mod %s in version.properties, using", internalVersion, getModId()); + FMLLog.log(getModId(), Level.FINE, "Found version %s for mod %s in version.properties, using", internalVersion, getModId()); } } if (Strings.isNullOrEmpty(internalVersion) && !Strings.isNullOrEmpty(modMetadata.version)) { - FMLLog.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.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); internalVersion = modMetadata.version; } if (Strings.isNullOrEmpty(internalVersion)) { - FMLLog.warning("Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId()); + FMLLog.log(getModId(), Level.WARNING, "Mod %s is missing the required element 'version' and no fallback can be found. Substituting '1.0'.", getModId()); modMetadata.version = internalVersion = "1.0"; } @@ -212,7 +212,7 @@ public class FMLModContainer implements ModContainer { try { - FMLLog.fine("Attempting to load the file version.properties from %s to locate a version number for %s", getSource().getName(), getModId()); + FMLLog.log(getModId(), Level.FINE,"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()) { @@ -241,7 +241,7 @@ public class FMLModContainer implements ModContainer catch (Exception e) { Throwables.propagateIfPossible(e); - FMLLog.fine("Failed to find a usable version.properties file"); + FMLLog.log(getModId(), Level.FINEST, "Failed to find a usable version.properties file"); return null; } } @@ -293,7 +293,7 @@ public class FMLModContainer implements ModContainer { if (this.enabled) { - FMLLog.fine("Enabling mod %s", getModId()); + FMLLog.log(getModId(), Level.FINE, "Enabling mod %s", getModId()); this.eventBus = bus; this.controller = controller; eventBus.register(this); @@ -324,7 +324,7 @@ public class FMLModContainer implements ModContainer } else { - FMLLog.severe("The mod %s appears to have an invalid method annotation %s. This annotation can only apply to methods with argument types %s -it will not be called", getModId(), a.annotationType().getSimpleName(), Arrays.toString(paramTypes)); + FMLLog.log(getModId(), Level.SEVERE,"The mod %s appears to have an invalid method annotation %s. This annotation can only apply to methods with argument types %s -it will not be called", getModId(), a.annotationType().getSimpleName(), Arrays.toString(paramTypes)); } } } @@ -388,7 +388,7 @@ public class FMLModContainer implements ModContainer catch (Exception e) { Throwables.propagateIfPossible(e); - FMLLog.log(Level.WARNING, e, "Attempting to load @%s in class %s for %s and failing", annotationName, targets.getClassName(), mc.getModId()); + FMLLog.log(getModId(), Level.WARNING, e, "Attempting to load @%s in class %s for %s and failing", annotationName, targets.getClassName(), mc.getModId()); } } if (f != null) @@ -399,7 +399,7 @@ public class FMLModContainer implements ModContainer target = modInstance; if (!modInstance.getClass().equals(clz)) { - FMLLog.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.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()); continue; } } @@ -445,7 +445,7 @@ public class FMLModContainer implements ModContainer { warnLevel = Level.FINER; } - FMLLog.log(warnLevel, "The mod %s is expecting signature %s for source %s, however there is no signature matching that description", getModId(), expectedFingerprint, source.getName()); + 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()); } else { diff --git a/fml/common/cpw/mods/fml/common/LoadController.java b/fml/common/cpw/mods/fml/common/LoadController.java index 123e9962ac..191346caf4 100644 --- a/fml/common/cpw/mods/fml/common/LoadController.java +++ b/fml/common/cpw/mods/fml/common/LoadController.java @@ -95,19 +95,29 @@ public class LoadController StringBuilder sb = new StringBuilder(); printModStates(sb); FMLLog.getLogger().severe(sb.toString()); - FMLLog.severe("The following problems were captured during this phase"); - for (Entry error : errors.entries()) + if (errors.size()>0) { - FMLLog.log(Level.SEVERE, error.getValue(), "Caught exception from %s", error.getKey()); - if (error.getValue() instanceof IFMLHandledException) + FMLLog.severe("The following problems were captured during this phase"); + for (Entry error : errors.entries()) { - toThrow = error.getValue(); - } - else if (toThrow == null) - { - toThrow = error.getValue(); + FMLLog.log(Level.SEVERE, error.getValue(), "Caught exception from %s", error.getKey()); + if (error.getValue() instanceof IFMLHandledException) + { + toThrow = error.getValue(); + } + else if (toThrow == null) + { + toThrow = error.getValue(); + } } } + else + { + FMLLog.severe("The ForgeModLoader state engine has become corrupted. Probably, a state was missed by and invalid modification to a base class" + + "ForgeModLoader depends on. This is a critical error and not recoverable. Investigate any modifications to base classes outside of" + + "ForgeModLoader, especially Optifine, to see if there are fixes available."); + throw new RuntimeException("The ForgeModLoader state engine is invalid"); + } if (toThrow != null && toThrow instanceof RuntimeException) { throw (RuntimeException)toThrow; @@ -136,9 +146,9 @@ public class LoadController activeContainer = mc; String modId = mc.getModId(); stateEvent.applyModContainer(activeContainer()); - FMLLog.finer("Sending event %s to mod %s", stateEvent.getEventType(), modId); + FMLLog.log(modId, Level.FINEST, "Sending event %s to mod %s", stateEvent.getEventType(), modId); eventChannels.get(modId).post(stateEvent); - FMLLog.finer("Sent event %s to mod %s", stateEvent.getEventType(), modId); + FMLLog.log(modId, Level.FINEST, "Sent event %s to mod %s", stateEvent.getEventType(), modId); activeContainer = null; if (stateEvent instanceof FMLStateEvent) { diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index ba00126ee1..04f4e0d831 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -61,6 +61,7 @@ import cpw.mods.fml.common.toposort.ModSortingException; 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; /** * The loader class performs the actual loading of the mod code from disk. @@ -142,6 +143,7 @@ public class Loader private static File minecraftDir; private static List injectedContainers; + private File loggingProperties; public static Loader instance() { @@ -186,7 +188,7 @@ public class Loader */ private void sortModList() { - FMLLog.fine("Verifying mod requirements are satisfied"); + FMLLog.finer("Verifying mod requirements are satisfied"); try { BiMap modVersions = HashBiMap.create(); @@ -238,13 +240,13 @@ public class Loader } } - FMLLog.fine("All mod requirements are satisfied"); + FMLLog.finer("All mod requirements are satisfied"); ModSorter sorter = new ModSorter(getActiveModList(), namedMods); try { - FMLLog.fine("Sorting mods into an ordered list"); + FMLLog.finer("Sorting mods into an ordered list"); List sortedMods = sorter.sort(); // Reset active list to the sorted list modController.getActiveModList().clear(); @@ -253,7 +255,7 @@ public class Loader mods.removeAll(sortedMods); sortedMods.addAll(mods); mods = sortedMods; - FMLLog.fine("Mod sorting completed successfully"); + FMLLog.finer("Mod sorting completed successfully"); } catch (ModSortingException sortException) { @@ -266,17 +268,19 @@ public class Loader } finally { - FMLLog.fine("Mod sorting data:"); + FMLLog.fine("Mod sorting data"); + int unprintedMods = mods.size(); for (ModContainer mod : getActiveModList()) { if (!mod.isImmutable()) { FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), mod.getSortingRules()); + unprintedMods--; } } - if (mods.size()==0) + if (unprintedMods == mods.size()) { - FMLLog.fine("No mods found to sort"); + FMLLog.fine("No user mods found to sort"); } } @@ -335,6 +339,10 @@ 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; } @@ -435,6 +443,11 @@ 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() @@ -456,6 +469,9 @@ public class Loader modController.transition(LoaderState.LOADING); ModDiscoverer disc = identifyMods(); disableRequestedMods(); + FMLLog.fine("Reloading logging properties from %s", loggingProperties.getPath()); + FMLRelaunchLog.loadLogConfiguration(loggingProperties); + FMLLog.fine("Reloaded logging properties"); modController.distributeStateMessage(FMLLoadEvent.class); sortModList(); mods = ImmutableList.copyOf(mods); @@ -476,7 +492,7 @@ public class Loader } modController.transition(LoaderState.CONSTRUCTING); modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader, disc.getASMTable()); - FMLLog.fine("Mod signature data:"); + FMLLog.fine("Mod signature data"); for (ModContainer mod : getActiveModList()) { FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), CertificateHelper.getFingerprint(mod.getSigningCertificate())); @@ -489,22 +505,22 @@ public class Loader private void disableRequestedMods() { String forcedModList = System.getProperty("fml.modStates", ""); - FMLLog.fine("Received a system property request \'%s\'",forcedModList); + FMLLog.finer("Received a system property request \'%s\'",forcedModList); Map sysPropertyStateList = Splitter.on(CharMatcher.anyOf(";:")) .omitEmptyStrings().trimResults().withKeyValueSeparator("=") .split(forcedModList); - FMLLog.fine("System property request managing the state of %d mods", sysPropertyStateList.size()); + FMLLog.finer("System property request managing the state of %d mods", sysPropertyStateList.size()); Map modStates = Maps.newHashMap(); File forcedModFile = new File(canonicalConfigDir, "fmlModState.properties"); Properties forcedModListProperties = new Properties(); if (forcedModFile.exists() && forcedModFile.isFile()) { - FMLLog.fine("Found a mod state file %s", forcedModFile.getName()); + FMLLog.finer("Found a mod state file %s", forcedModFile.getName()); try { forcedModListProperties.load(new FileReader(forcedModFile)); - FMLLog.fine("Loaded states for %d mods from file", forcedModListProperties.size()); + FMLLog.finer("Loaded states for %d mods from file", forcedModListProperties.size()); } catch (Exception e) { diff --git a/fml/common/cpw/mods/fml/common/ModClassLoader.java b/fml/common/cpw/mods/fml/common/ModClassLoader.java index b5d8bf4ceb..2b69592ebd 100644 --- a/fml/common/cpw/mods/fml/common/ModClassLoader.java +++ b/fml/common/cpw/mods/fml/common/ModClassLoader.java @@ -70,7 +70,7 @@ public class ModClassLoader extends URLClassLoader } catch (URISyntaxException e) { - FMLLog.log(Level.SEVERE, "Unable to process our input to locate the minecraft code", e); + FMLLog.log(Level.SEVERE, e, "Unable to process our input to locate the minecraft code"); throw new LoaderException(e); } } diff --git a/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java index 411eb8a9a9..991d48e5f2 100644 --- a/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java +++ b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java @@ -44,7 +44,7 @@ public class ModDiscoverer { if (knownLibraries.contains(minecraftSources[i].getName())) { - FMLLog.fine("Skipping known library file %s", minecraftSources[i].getAbsolutePath()); + FMLLog.finer("Skipping known library file %s", minecraftSources[i].getAbsolutePath()); } else { diff --git a/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java b/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java index 4bd09b866c..a0dbfab3ca 100644 --- a/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java +++ b/fml/common/cpw/mods/fml/common/event/FMLPreInitializationEvent.java @@ -81,6 +81,8 @@ public class FMLPreInitializationEvent extends FMLStateEvent /** * Get a logger instance configured to write to the FML Log as a parent, identified by modid. Handy for mod logging! + * Configurations can be applied through the config/logging.properties file, specifying logging levels + * for your ModID. Use this! * * @return A logger */ diff --git a/fml/common/cpw/mods/fml/common/registry/GameData.java b/fml/common/cpw/mods/fml/common/registry/GameData.java index 3929d37874..5514765225 100644 --- a/fml/common/cpw/mods/fml/common/registry/GameData.java +++ b/fml/common/cpw/mods/fml/common/registry/GameData.java @@ -50,13 +50,13 @@ public class GameData { ignoredMods = Maps.fromProperties(p); if (ignoredMods.size()>0) { - FMLLog.warning("Using non-empty ignored mods configuration file %s", ignoredMods.keySet()); + FMLLog.log("fml.ItemTracker", Level.WARNING, "Using non-empty ignored mods configuration file %s", ignoredMods.keySet()); } } catch (Exception e) { Throwables.propagateIfPossible(e); - FMLLog.log(Level.SEVERE, e, "Failed to read ignored ID checker mods properties file"); + FMLLog.log("fml.ItemTracker", Level.SEVERE, e, "Failed to read ignored ID checker mods properties file"); ignoredMods = ImmutableMap.of(); } } @@ -84,12 +84,12 @@ public class GameData { if (idMap.containsKey(item.field_77779_bT)) { ItemData id = idMap.get(item.field_77779_bT); - FMLLog.info("[ItemTracker] The mod %s is overwriting existing item at %d (%s from %s) with %s", mc.getModId(), id.getItemId(), id.getItemType(), id.getModId(), itemType); + FMLLog.log("fml.ItemTracker", Level.INFO, "The mod %s is overwriting existing item at %d (%s from %s) with %s", mc.getModId(), id.getItemId(), id.getItemType(), id.getModId(), itemType); } idMap.put(item.field_77779_bT, itemData); if (!"Minecraft".equals(mc.getModId())) { - FMLLog.fine("[ItemTracker] Adding item %s(%d) owned by %s", item.getClass().getName(), item.field_77779_bT, mc.getModId()); + FMLLog.log("fml.ItemTracker",Level.FINE, "Adding item %s(%d) owned by %s", item.getClass().getName(), item.field_77779_bT, mc.getModId()); } } @@ -119,12 +119,12 @@ public class GameData { Map worldMap = Maps.uniqueIndex(worldSaveItems,idMapFunction); difference = Maps.difference(worldMap, idMap); - FMLLog.fine("The difference set is %s", difference); + FMLLog.log("fml.ItemTracker", Level.FINE, "The difference set is %s", difference); if (!difference.entriesDiffering().isEmpty() || !difference.entriesOnlyOnLeft().isEmpty()) { - FMLLog.severe("FML has detected item discrepancies"); - FMLLog.severe("Missing items : %s", difference.entriesOnlyOnLeft()); - FMLLog.severe("Mismatched items : %s", difference.entriesDiffering()); + FMLLog.log("fml.ItemTracker", Level.SEVERE, "FML has detected item discrepancies"); + FMLLog.log("fml.ItemTracker", Level.SEVERE, "Missing items : %s", difference.entriesOnlyOnLeft()); + FMLLog.log("fml.ItemTracker", Level.SEVERE, "Mismatched items : %s", difference.entriesDiffering()); boolean foundNonIgnored = false; for (ItemData diff : difference.entriesOnlyOnLeft().values()) { @@ -142,7 +142,7 @@ public class GameData { } if (!foundNonIgnored) { - FMLLog.severe("FML is ignoring these ID discrepancies because of configuration. YOUR GAME WILL NOW PROBABLY CRASH. HOPEFULLY YOU WON'T HAVE CORRUPTED YOUR WORLD. BLAME %s", ignoredMods.keySet()); + FMLLog.log("fml.ItemTracker", Level.SEVERE, "FML is ignoring these ID discrepancies because of configuration. YOUR GAME WILL NOW PROBABLY CRASH. HOPEFULLY YOU WON'T HAVE CORRUPTED YOUR WORLD. BLAME %s", ignoredMods.keySet()); } isSaveValid = !foundNonIgnored; serverValidationLatch.countDown(); diff --git a/fml/common/cpw/mods/fml/common/registry/LanguageRegistry.java b/fml/common/cpw/mods/fml/common/registry/LanguageRegistry.java index ba1270e50b..1de27d199f 100644 --- a/fml/common/cpw/mods/fml/common/registry/LanguageRegistry.java +++ b/fml/common/cpw/mods/fml/common/registry/LanguageRegistry.java @@ -7,6 +7,7 @@ import java.net.URL; import java.util.HashMap; import java.util.Map; import java.util.Properties; +import java.util.logging.Level; import com.google.common.base.Charsets; @@ -142,8 +143,7 @@ public class LanguageRegistry addStringLocalization(langPack, lang); } catch (IOException e) { - FMLLog.getLogger().severe("Unable to load localization from file: " + localizationFile); - e.printStackTrace(); + FMLLog.log(Level.SEVERE, e, "Unable to load localization from file %s", localizationFile); } finally { try { @@ -152,7 +152,7 @@ public class LanguageRegistry } } catch (IOException ex) { - ex.printStackTrace(); + // HUSH } } } diff --git a/fml/common/cpw/mods/fml/relauncher/FMLRelaunchLog.java b/fml/common/cpw/mods/fml/relauncher/FMLRelaunchLog.java index 17529820fc..88d85830cf 100644 --- a/fml/common/cpw/mods/fml/relauncher/FMLRelaunchLog.java +++ b/fml/common/cpw/mods/fml/relauncher/FMLRelaunchLog.java @@ -2,6 +2,8 @@ package cpw.mods.fml.relauncher; import java.io.ByteArrayOutputStream; import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintStream; import java.util.concurrent.Executors; @@ -112,7 +114,7 @@ public class FMLRelaunchLog } /** * Our special logger for logging issues to. We copy various assets from the - * Minecraft logger to acheive a similar appearance. + * Minecraft logger to achieve a similar appearance. */ public static FMLRelaunchLog log = new FMLRelaunchLog(); @@ -124,6 +126,10 @@ public class FMLRelaunchLog private static PrintStream errCache; private Logger myLog; + private static FileHandler fileHandler; + + private static FMLLogFormatter formatter; + private FMLRelaunchLog() { } @@ -142,37 +148,66 @@ public class FMLRelaunchLog stdOut.setParent(log.myLog); Logger stdErr = Logger.getLogger("STDERR"); stdErr.setParent(log.myLog); - FMLLogFormatter formatter = new FMLLogFormatter(); - - // Console handler captures the normal stderr before it gets replaced + log.myLog.setLevel(Level.ALL); log.myLog.setUseParentHandlers(false); - log.myLog.addHandler(new ConsoleLogWrapper()); consoleLogThread = new Thread(new ConsoleLogThread()); consoleLogThread.start(); - ConsoleLogThread.wrappedHandler.setLevel(Level.parse(System.getProperty("fml.log.level","INFO"))); - ConsoleLogThread.wrappedHandler.setFormatter(formatter); - log.myLog.setLevel(Level.ALL); + formatter = new FMLLogFormatter(); try { File logPath = new File(minecraftHome, FMLRelauncher.logFileNamePattern); - FileHandler fileHandler = new FileHandler(logPath.getPath(), 0, 3); - fileHandler.setFormatter(formatter); - fileHandler.setLevel(Level.ALL); - log.myLog.addHandler(fileHandler); + fileHandler = new FileHandler(logPath.getPath(), 0, 3) + { + public synchronized void close() throws SecurityException { + // We don't want this handler to reset + } + }; } catch (Exception e) { } + 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)); - // Reset global logging to shut up other logging sources (thanks guava!) 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); + } + + public static void loadLogConfiguration(File logConfigFile) + { + 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)); + } public static void log(Level level, String format, Object... data) { @@ -183,6 +218,12 @@ 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) + { + makeLog(logChannel); + Logger.getLogger(logChannel).log(level, String.format(format, data), ex); + } + public static void log(Level level, Throwable ex, String format, Object... data) { if (!configured) @@ -225,4 +266,9 @@ public class FMLRelaunchLog { return myLog; } + public static void makeLog(String logChannel) + { + Logger l = Logger.getLogger(logChannel); + l.setParent(log.myLog); + } } From 46ccfb235d1667569f29cfaaff94ce04b1908b36 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 30 Jan 2013 20:55:12 -0500 Subject: [PATCH 6/7] More logging tweaks. You can probably configure individual mod log files if you wish now --- fml/common/cpw/mods/fml/common/LoadController.java | 7 +++++-- fml/common/cpw/mods/fml/common/Loader.java | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/fml/common/cpw/mods/fml/common/LoadController.java b/fml/common/cpw/mods/fml/common/LoadController.java index 191346caf4..c9f1cb9ce5 100644 --- a/fml/common/cpw/mods/fml/common/LoadController.java +++ b/fml/common/cpw/mods/fml/common/LoadController.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; +import java.util.logging.Logger; import com.google.common.base.Joiner; import com.google.common.collect.ArrayListMultimap; @@ -60,14 +61,16 @@ public class LoadController boolean isActive = mod.registerBus(bus, this); if (isActive) { - FMLLog.fine("Activating mod %s", mod.getModId()); + Level level = Logger.getLogger(mod.getModId()).getLevel(); + FMLLog.log(mod.getModId(), Level.FINE, "Mod Logging channel %s configured at %s level.", 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); } else { - FMLLog.warning("Mod %s has been disabled through configuration", mod.getModId()); + FMLLog.log(mod.getModId(), Level.WARNING, "Mod %s has been disabled through configuration", mod.getModId()); modStates.put(mod.getModId(), ModState.UNLOADED); modStates.put(mod.getModId(), ModState.DISABLED); } diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index 04f4e0d831..a48a775443 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -497,6 +497,10 @@ public class Loader { FMLLog.fine("\t%s(%s:%s): %s (%s)", mod.getModId(), mod.getName(), mod.getVersion(), mod.getSource().getName(), CertificateHelper.getFingerprint(mod.getSigningCertificate())); } + if (getActiveModList().isEmpty()) + { + FMLLog.fine("No user mod signature data found"); + } modController.transition(LoaderState.PREINITIALIZATION); modController.distributeStateMessage(LoaderState.PREINITIALIZATION, disc.getASMTable(), canonicalConfigDir); modController.transition(LoaderState.INITIALIZATION); From 3101006e5867b4b1d4dfebd69ffad0023e1fc2be Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 31 Jan 2013 13:39:53 -0500 Subject: [PATCH 7/7] IMC tweaks: runtimeMessages now work (thanks for all that testing for this much requested feature!) and IMCEvent will no longer remove messages if no one gets them, so you can do just manual runtime polling, if you wish. --- .../cpw/mods/fml/common/event/FMLInterModComms.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fml/common/cpw/mods/fml/common/event/FMLInterModComms.java b/fml/common/cpw/mods/fml/common/event/FMLInterModComms.java index a2d7e02f96..31f9f1131c 100644 --- a/fml/common/cpw/mods/fml/common/event/FMLInterModComms.java +++ b/fml/common/cpw/mods/fml/common/event/FMLInterModComms.java @@ -44,17 +44,23 @@ public class FMLInterModComms { * */ public static class IMCEvent extends FMLEvent { + private ModContainer activeContainer; + @Override public void applyModContainer(ModContainer activeContainer) { - currentList = ImmutableList.copyOf(modMessages.removeAll(activeContainer.getModId())); - FMLLog.finest("Attempting to deliver %d IMC messages to mod %s", currentList.size(), activeContainer.getModId()); + this.activeContainer = activeContainer; + FMLLog.finest("Attempting to deliver %d IMC messages to mod %s", modMessages.get(activeContainer.getModId()).size(), activeContainer.getModId()); } private ImmutableList currentList; public ImmutableList getMessages() { + if (currentList == null) + { + currentList = ImmutableList.copyOf(modMessages.removeAll(activeContainer.getModId())); + } return currentList; } } @@ -202,7 +208,7 @@ public class FMLInterModComms { ModContainer mc = FMLCommonHandler.instance().findContainerFor(forMod); if (mc != null) { - return ImmutableList.copyOf(modMessages.removeAll(mc)); + return ImmutableList.copyOf(modMessages.removeAll(mc.getModId())); } else {