mirror of
https://github.com/LegacyModdingMC/UniMix.git
synced 2026-11-28 23:59:38 +00:00
Write some debugging info to the console if verbose logging is enabled
This commit is contained in:
1 parent
b88bbba2fe
commit
31ac58030c
2 files changed
+44
-2
No files matched your search
@@ -30,6 +30,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.logging.log4j.core.helpers.Booleans;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
import org.spongepowered.asm.util.PrettyPrinter;
|
||||
|
||||
import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
@@ -149,12 +150,12 @@ public class MixinEnvironment {
|
||||
* Parent option to this option, if non-null then this option is enabled
|
||||
* if
|
||||
*/
|
||||
private final Option parent;
|
||||
final Option parent;
|
||||
|
||||
/**
|
||||
* Java property name
|
||||
*/
|
||||
private final String property;
|
||||
final String property;
|
||||
|
||||
private Option(String property) {
|
||||
this(null, property);
|
||||
@@ -204,6 +205,18 @@ public class MixinEnvironment {
|
||||
for (Option option : Option.values()) {
|
||||
this.options[option.ordinal()] = option.getValue();
|
||||
}
|
||||
|
||||
if (this.getOption(Option.DEBUG_VERBOSE)) {
|
||||
PrettyPrinter printer = new PrettyPrinter(32);
|
||||
printer.add("SpongePowered MIXIN (Verbose debugging enabled)").centre().hr();
|
||||
printer.add("%24s : %s", "Code source", this.getClass().getProtectionDomain().getCodeSource().getLocation());
|
||||
printer.add("%24s : %s", "Internal Version", version).hr();
|
||||
for (Option option : Option.values()) {
|
||||
printer.add("%24s : %s%s", option.property, option.parent == null ? "" : " - ", this.getOption(option));
|
||||
}
|
||||
printer.hr().add("%24s : %s", "Detected Side", this.getSide());
|
||||
printer.print(System.err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,6 +40,11 @@ public class PrettyPrinter {
|
||||
* "Horizontal rule" marker
|
||||
*/
|
||||
private static final String HR = "---";
|
||||
|
||||
/**
|
||||
* If specified as the first character on a line, centres the line
|
||||
*/
|
||||
private static final char CENTRE = '\252';
|
||||
|
||||
/**
|
||||
* Box with (adapts to contents)
|
||||
@@ -51,6 +56,14 @@ public class PrettyPrinter {
|
||||
*/
|
||||
private final List<String> lines = new ArrayList<String>();
|
||||
|
||||
public PrettyPrinter() {
|
||||
this(100);
|
||||
}
|
||||
|
||||
public PrettyPrinter(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a blank line to the output
|
||||
*
|
||||
@@ -85,6 +98,18 @@ public class PrettyPrinter {
|
||||
this.lines.add(PrettyPrinter.HR);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Centre the last line added
|
||||
*
|
||||
* @return fluent interface
|
||||
*/
|
||||
public PrettyPrinter centre() {
|
||||
if (!this.lines.isEmpty()) {
|
||||
this.lines.add(PrettyPrinter.CENTRE + this.lines.remove(this.lines.size() - 1));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print this printer to the specified output
|
||||
@@ -97,6 +122,10 @@ public class PrettyPrinter {
|
||||
if (line == PrettyPrinter.HR) {
|
||||
this.printHr(stream);
|
||||
} else {
|
||||
if (line.length() > 0 && line.charAt(0) == PrettyPrinter.CENTRE) {
|
||||
String text = line.substring(1);
|
||||
line = String.format("%" + (((this.width - (text.length())) / 2) + text.length()) + "s", text);
|
||||
}
|
||||
stream.printf("/* %-" + this.width + "s */\n", line);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user