Commit 36ff51e41a08b9fa356e5949f31830881b09ceeb

Authored by Mumfrey
1 parent 68f130d2

+ Improved logger behaviour

+ Fixed class path splitting on mac
java/com/mumfrey/liteloader/core/LiteLoader.java
@@ -17,14 +17,17 @@ import java.util.HashMap; @@ -17,14 +17,17 @@ import java.util.HashMap;
17 import java.util.Iterator; 17 import java.util.Iterator;
18 import java.util.LinkedList; 18 import java.util.LinkedList;
19 import java.util.Map; 19 import java.util.Map;
  20 +import java.util.logging.ConsoleHandler;
  21 +import java.util.logging.FileHandler;
  22 +import java.util.logging.Formatter;
20 import java.util.logging.Logger; 23 import java.util.logging.Logger;
21 -import java.util.logging.SimpleFormatter;  
22 import java.util.logging.StreamHandler; 24 import java.util.logging.StreamHandler;
23 import java.util.zip.ZipEntry; 25 import java.util.zip.ZipEntry;
24 import java.util.zip.ZipFile; 26 import java.util.zip.ZipFile;
25 import java.util.zip.ZipInputStream; 27 import java.util.zip.ZipInputStream;
26 28
27 import net.minecraft.client.Minecraft; 29 import net.minecraft.client.Minecraft;
  30 +import net.minecraft.src.ConsoleLogManager;
28 import net.minecraft.src.IntHashMap; 31 import net.minecraft.src.IntHashMap;
29 import net.minecraft.src.NetHandler; 32 import net.minecraft.src.NetHandler;
30 import net.minecraft.src.Packet; 33 import net.minecraft.src.Packet;
@@ -34,8 +37,8 @@ import net.minecraft.src.Timer; @@ -34,8 +37,8 @@ import net.minecraft.src.Timer;
34 37
35 import com.mumfrey.liteloader.ChatFilter; 38 import com.mumfrey.liteloader.ChatFilter;
36 import com.mumfrey.liteloader.ChatListener; 39 import com.mumfrey.liteloader.ChatListener;
37 -import com.mumfrey.liteloader.LoginListener;  
38 import com.mumfrey.liteloader.LiteMod; 40 import com.mumfrey.liteloader.LiteMod;
  41 +import com.mumfrey.liteloader.LoginListener;
39 import com.mumfrey.liteloader.Tickable; 42 import com.mumfrey.liteloader.Tickable;
40 43
41 /** 44 /**
@@ -63,8 +66,6 @@ public final class LiteLoader implements FilenameFilter @@ -63,8 +66,6 @@ public final class LiteLoader implements FilenameFilter
63 */ 66 */
64 private static Logger logger = Logger.getLogger("liteloader"); 67 private static Logger logger = Logger.getLogger("liteloader");
65 68
66 - private File logFile;  
67 -  
68 /** 69 /**
69 * "mods" folder which contains mods and config files 70 * "mods" folder which contains mods and config files
70 */ 71 */
@@ -158,6 +159,20 @@ public final class LiteLoader implements FilenameFilter @@ -158,6 +159,20 @@ public final class LiteLoader implements FilenameFilter
158 // addURL method is used by the class loader to 159 // addURL method is used by the class loader to
159 mAddUrl = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); 160 mAddUrl = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
160 mAddUrl.setAccessible(true); 161 mAddUrl.setAccessible(true);
  162 +
  163 + ConsoleLogManager.func_73699_a();
  164 + Formatter minecraftLogFormatter = ConsoleLogManager.loggerLogManager.getHandlers()[0].getFormatter();
  165 +
  166 + logger.setUseParentHandlers(false);
  167 +
  168 + StreamHandler consoleHandler = new ConsoleHandler();
  169 + consoleHandler.setFormatter(minecraftLogFormatter);
  170 + logger.addHandler(consoleHandler);
  171 +
  172 + FileHandler logFileHandler = new FileHandler(new File(Minecraft.getMinecraftDir(), "LiteLoader.txt").getAbsolutePath());
  173 + logFileHandler.setFormatter(minecraftLogFormatter);
  174 + logger.addHandler(logFileHandler);
  175 +
161 } 176 }
162 catch (Exception ex) 177 catch (Exception ex)
163 { 178 {
@@ -165,7 +180,6 @@ public final class LiteLoader implements FilenameFilter @@ -165,7 +180,6 @@ public final class LiteLoader implements FilenameFilter
165 ex.printStackTrace(); 180 ex.printStackTrace();
166 } 181 }
167 182
168 - logger.addHandler(new StreamHandler(System.err, new SimpleFormatter()));  
169 } 183 }
170 184
171 /** 185 /**
@@ -214,7 +228,8 @@ public final class LiteLoader implements FilenameFilter @@ -214,7 +228,8 @@ public final class LiteLoader implements FilenameFilter
214 { 228 {
215 logger.info("Loading mods from class path"); 229 logger.info("Loading mods from class path");
216 230
217 - String[] classPathEntries = System.getProperty("java.class.path").split(";"); 231 + String classPathSeparator = System.getProperty("path.separator");
  232 + String[] classPathEntries = System.getProperty("java.class.path").split(classPathSeparator);
218 modsToLoad = findModClasses(classPathEntries, modFiles); 233 modsToLoad = findModClasses(classPathEntries, modFiles);
219 } 234 }
220 catch (Exception ex) 235 catch (Exception ex)