Commit 97de196eea75cd0b4afee61664b61485038adf38

Authored by Mumfrey
1 parent b3097a72

minor refactoring and logging output changes

java/client/com/mumfrey/liteloader/client/gui/GuiPanelLiteLoaderLog.java
@@ -23,7 +23,7 @@ import com.mumfrey.liteloader.util.net.LiteLoaderLogUpload; @@ -23,7 +23,7 @@ import com.mumfrey.liteloader.util.net.LiteLoaderLogUpload;
23 */ 23 */
24 class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent 24 class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent
25 { 25 {
26 - private static boolean useNativeRes = false; 26 + private static boolean useNativeRes = true;
27 27
28 /** 28 /**
29 * Scroll pane 29 * Scroll pane
@@ -226,7 +226,7 @@ class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent @@ -226,7 +226,7 @@ class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent
226 { 226 {
227 if (yPos > scrollAmount - 10 && yPos <= scrollAmount + height) 227 if (yPos > scrollAmount - 10 && yPos <= scrollAmount + height)
228 { 228 {
229 - this.mc.fontRendererObj.drawString(logLine, 0, yPos, this.getMessageColour(logLine.toLowerCase())); 229 + this.mc.fontRendererObj.drawString(logLine, 0, yPos, this.getMessageColour(logLine.toLowerCase().substring(11)));
230 } 230 }
231 yPos += 10; 231 yPos += 10;
232 } 232 }
@@ -259,6 +259,14 @@ class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent @@ -259,6 +259,14 @@ class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent
259 if (logLine.startsWith("calling late")) return 0x00AAAA; 259 if (logLine.startsWith("calling late")) return 0x00AAAA;
260 if (logLine.startsWith("dependency check")) return 0xFFAA00; 260 if (logLine.startsWith("dependency check")) return 0xFFAA00;
261 if (logLine.startsWith("dependency")) return 0xFF5500; 261 if (logLine.startsWith("dependency")) return 0xFF5500;
  262 + if (logLine.startsWith("mod name collision")) return 0xAA0000;
  263 + if (logLine.startsWith("registering discovery module")) return 0x55FF55;
  264 + if (logLine.startsWith("registering interface provider")) return 0xFFAA00;
  265 + if (logLine.startsWith("mod file '")) return 0xFFAA00;
  266 + if (logLine.startsWith("classtransformer '")) return 0x5555FF;
  267 + if (logLine.startsWith("tweakClass '")) return 0x5555FF;
  268 + if (logLine.startsWith("baking listener list")) return 0x00AAAA;
  269 + if (logLine.startsWith("generating new event handler")) return 0xFFFF55;
262 270
263 return 0xCCCCCC; 271 return 0xCCCCCC;
264 } 272 }
java/common/com/mumfrey/liteloader/core/LiteLoaderEnumerator.java
@@ -453,15 +453,28 @@ public class LiteLoaderEnumerator implements LoaderEnumerator @@ -453,15 +453,28 @@ public class LiteLoaderEnumerator implements LoaderEnumerator
453 453
454 if (container != null) 454 if (container != null)
455 { 455 {
456 - if (container.isEnabled(this.environment) && this.checkDependencies(container) && this.checkAPIRequirements(container)) 456 + if (!container.isEnabled(this.environment))
457 { 457 {
458 - this.registerEnabledContainer(container); 458 + LiteLoaderLogger.info("Container %s is disabled", container.getLocation());
  459 + this.registerDisabledContainer(container);
  460 + return false;
459 } 461 }
460 - else 462 +
  463 + if (!this.checkDependencies(container))
461 { 464 {
  465 + LiteLoaderLogger.info("Container %s is missing one or more dependencies", container.getLocation());
462 this.registerDisabledContainer(container); 466 this.registerDisabledContainer(container);
463 return false; 467 return false;
464 } 468 }
  469 +
  470 + if (!this.checkAPIRequirements(container))
  471 + {
  472 + LiteLoaderLogger.info("Container %s is missing one or more required APIs", container.getLocation());
  473 + this.registerDisabledContainer(container);
  474 + return false;
  475 + }
  476 +
  477 + this.registerEnabledContainer(container);
465 } 478 }
466 479
467 return true; 480 return true;
java/common/com/mumfrey/liteloader/core/api/EnumeratorModuleFolder.java
@@ -36,20 +36,20 @@ public class EnumeratorModuleFolder implements FilenameFilter, EnumeratorModule @@ -36,20 +36,20 @@ public class EnumeratorModuleFolder implements FilenameFilter, EnumeratorModule
36 /** 36 /**
37 * Ordered sets used to sort mods by version/revision 37 * Ordered sets used to sort mods by version/revision
38 */ 38 */
39 - private final Map<String, TreeSet<LoadableMod<File>>> versionOrderingSets = new HashMap<String, TreeSet<LoadableMod<File>>>(); 39 + protected final Map<String, TreeSet<LoadableMod<File>>> versionOrderingSets = new HashMap<String, TreeSet<LoadableMod<File>>>();
40 40
41 /** 41 /**
42 * Mods to add once init is completed 42 * Mods to add once init is completed
43 */ 43 */
44 - private final List<LoadableMod<File>> loadableMods = new ArrayList<LoadableMod<File>>(); 44 + protected final List<LoadableMod<File>> loadableMods = new ArrayList<LoadableMod<File>>();
45 45
46 - private LiteLoaderCoreAPI coreAPI; 46 + protected LiteLoaderCoreAPI coreAPI;
47 47
48 - private File directory; 48 + protected File directory;
49 49
50 - private boolean readZipFiles;  
51 - private boolean readJarFiles;  
52 - private boolean loadTweaks; 50 + protected boolean readZipFiles;
  51 + protected boolean readJarFiles;
  52 + protected boolean loadTweaks;
53 53
54 /** 54 /**
55 * True if this is a general, unversioned folder and the enumerator should only add files which have valid version metadata 55 * True if this is a general, unversioned folder and the enumerator should only add files which have valid version metadata
@@ -211,6 +211,16 @@ public class EnumeratorModuleFolder implements FilenameFilter, EnumeratorModule @@ -211,6 +211,16 @@ public class EnumeratorModuleFolder implements FilenameFilter, EnumeratorModule
211 } 211 }
212 212
213 /** 213 /**
  214 + * @param modFile
  215 + * @return
  216 + */
  217 + protected boolean isFileSupported(LoadableModFile modFile)
  218 + {
  219 + // Stub for subclasses
  220 + return LiteLoaderVersion.CURRENT.isVersionSupported(modFile.getTargetVersion());
  221 + }
  222 +
  223 + /**
214 * @param candidateFile 224 * @param candidateFile
215 * @param strVersion 225 * @param strVersion
216 */ 226 */
@@ -222,7 +232,7 @@ public class EnumeratorModuleFolder implements FilenameFilter, EnumeratorModule @@ -222,7 +232,7 @@ public class EnumeratorModuleFolder implements FilenameFilter, EnumeratorModule
222 { 232 {
223 // Only add the mod if the version matches, we add candidates to the versionOrderingSets in 233 // Only add the mod if the version matches, we add candidates to the versionOrderingSets in
224 // order to determine the most recent version available. 234 // order to determine the most recent version available.
225 - if (LiteLoaderVersion.CURRENT.isVersionSupported(modFile.getTargetVersion())) 235 + if (this.isFileSupported(modFile))
226 { 236 {
227 if (!this.versionOrderingSets.containsKey(modFile.getName())) 237 if (!this.versionOrderingSets.containsKey(modFile.getName()))
228 { 238 {
java/common/com/mumfrey/liteloader/transformers/event/EventInjectionTransformer.java
@@ -261,7 +261,7 @@ public abstract class EventInjectionTransformer extends ClassTransformer @@ -261,7 +261,7 @@ public abstract class EventInjectionTransformer extends ClassTransformer
261 Event head = events.iterator().next(); 261 Event head = events.iterator().next();
262 MethodNode handler = head.inject(injectionPoint, cancellable, this.globalEventID); 262 MethodNode handler = head.inject(injectionPoint, cancellable, this.globalEventID);
263 263
264 - LiteLoaderLogger.info("Injecting event %s with %d handlers in method %s in class %s", head.getName(), events.size(), method.name, classNode.name.replace('/', '.')); 264 + LiteLoaderLogger.info("Injecting %s[x%d] in %s in %s", head.getName(), events.size(), method.name, getSimpleClassName(classNode));
265 265
266 for (Event event : events) 266 for (Event event : events)
267 { 267 {
@@ -270,4 +270,11 @@ public abstract class EventInjectionTransformer extends ClassTransformer @@ -270,4 +270,11 @@ public abstract class EventInjectionTransformer extends ClassTransformer
270 270
271 this.globalEventID++; 271 this.globalEventID++;
272 } 272 }
  273 +
  274 + private static String getSimpleClassName(ClassNode classNode)
  275 + {
  276 + String className = classNode.name.replace('/', '.');
  277 + int dotPos = className.lastIndexOf('.');
  278 + return dotPos == -1 ? className : className.substring(dotPos + 1);
  279 + }
273 } 280 }
274 \ No newline at end of file 281 \ No newline at end of file
java/common/com/mumfrey/liteloader/util/log/LiteLoaderLogger.java
@@ -4,6 +4,7 @@ import java.io.IOException; @@ -4,6 +4,7 @@ import java.io.IOException;
4 import java.io.PrintWriter; 4 import java.io.PrintWriter;
5 import java.io.StringWriter; 5 import java.io.StringWriter;
6 import java.util.ArrayList; 6 import java.util.ArrayList;
  7 +import java.util.Date;
7 import java.util.LinkedList; 8 import java.util.LinkedList;
8 import java.util.List; 9 import java.util.List;
9 import java.util.MissingFormatArgumentException; 10 import java.util.MissingFormatArgumentException;
@@ -51,11 +52,11 @@ public class LiteLoaderLogger extends AbstractAppender @@ -51,11 +52,11 @@ public class LiteLoaderLogger extends AbstractAppender
51 synchronized (LiteLoaderLogger.logTail) 52 synchronized (LiteLoaderLogger.logTail)
52 { 53 {
53 LiteLoaderLogger.logIndex++; 54 LiteLoaderLogger.logIndex++;
54 - this.append(event.getMessage().getFormattedMessage()); 55 + this.append(event.getMillis(), event.getMessage().getFormattedMessage());
55 Throwable thrown = event.getThrown(); 56 Throwable thrown = event.getThrown();
56 if (thrown != null) 57 if (thrown != null)
57 { 58 {
58 - this.append(String.format("\2474%s: \2476%s", thrown.getClass().getSimpleName(), thrown.getMessage())); 59 + this.append(event.getMillis(), String.format("\2474%s: \2476%s", thrown.getClass().getSimpleName(), thrown.getMessage()));
59 } 60 }
60 } 61 }
61 } 62 }
@@ -63,16 +64,18 @@ public class LiteLoaderLogger extends AbstractAppender @@ -63,16 +64,18 @@ public class LiteLoaderLogger extends AbstractAppender
63 /** 64 /**
64 * @param message 65 * @param message
65 */ 66 */
66 - private void append(String message) 67 + private void append(long timestamp, String message)
67 { 68 {
  69 + String date = new java.text.SimpleDateFormat("[HH:mm:ss] ").format(new Date(timestamp));
  70 +
68 while (message.indexOf('\n') > -1) 71 while (message.indexOf('\n') > -1)
69 { 72 {
70 int LF = message.indexOf('\n'); 73 int LF = message.indexOf('\n');
71 - this.appendLine(message.substring(0, LF)); 74 + this.appendLine(date + message.substring(0, LF));
72 message = message.substring(LF + 1); 75 message = message.substring(LF + 1);
73 } 76 }
74 77
75 - this.appendLine(message); 78 + this.appendLine(date + message);
76 } 79 }
77 80
78 /** 81 /**