Skip to content

Commit 7b49edb

Browse files
committed
Revert "replaced slf4j with a custom logger"
This reverts commit 4c38d8d.
1 parent 4c38d8d commit 7b49edb

4 files changed

Lines changed: 10 additions & 44 deletions

File tree

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ repositories {
1313
dependencies {
1414
implementation 'org.ow2.asm:asm:9.8'
1515
implementation 'org.ow2.asm:asm-commons:9.8'
16+
compileOnly 'org.slf4j:slf4j-api:2.0.17'
1617
}
1718

1819
jar {

src/main/java/io/github/freehij/injections/KnotClassPathFixer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import io.github.freehij.loader.annotation.EditClass;
55
import io.github.freehij.loader.annotation.Inject;
66
import io.github.freehij.loader.util.InjectionHelper;
7-
import io.github.freehij.loader.util.Logger;
87

98
import java.net.URL;
109
import java.nio.file.Path;
@@ -13,15 +12,13 @@
1312
@SuppressWarnings("unchecked")
1413
@EditClass("net/fabricmc/loader/impl/game/minecraft/MinecraftGameProvider")
1514
public class KnotClassPathFixer {
16-
@Inject(method = "locateGame",
17-
descriptor = "(Lnet/fabricmc/loader/impl/launch/FabricLauncher;[Ljava/lang/String;)Z")
15+
@Inject(method = "locateGame", descriptor = "(Lnet/fabricmc/loader/impl/launch/FabricLauncher;[Ljava/lang/String;)Z")
1816
public static void locateGame(InjectionHelper helper) throws Exception {
1917
Collection<Path> miscGameLibraries =
2018
(Collection<Path>) helper.getReflector().getField("miscGameLibraries").get();
2119
miscGameLibraries.add(Path.of(Loader.class.getProtectionDomain().getCodeSource().getLocation().toURI()));
2220
for (URL url : Loader.getModUrls()) {
2321
miscGameLibraries.add(Path.of(url.toURI()));
2422
}
25-
Logger.debug("Applied knot class path fix", KnotClassPathFixer.class);
2623
}
2724
}

src/main/java/io/github/freehij/loader/Loader.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
import io.github.freehij.loader.annotation.EditClass;
55
import io.github.freehij.loader.annotation.Local;
66
import io.github.freehij.loader.constant.At;
7-
import io.github.freehij.loader.util.Logger;
87
import org.objectweb.asm.*;
8+
import org.slf4j.Logger;
9+
import org.slf4j.LoggerFactory;
910

1011
import java.io.*;
1112
import java.lang.instrument.ClassFileTransformer;
@@ -24,6 +25,7 @@
2425

2526
public class Loader {
2627
static final String VERSION = "a1.0.0";
28+
static final Logger LOGGER = LoggerFactory.getLogger("Loader");
2729
static final Map<String, List<InjectionPoint>> injectionPoints = new HashMap<>();
2830
static final List<ModInfo> mods = new ArrayList<>();
2931
static final List<URL> modUrls = new ArrayList<>();
@@ -61,9 +63,9 @@ static void defineMods(boolean log) {
6163
));
6264
loadMods();
6365
if (log) {
64-
Logger.info("Found mods:", "Loader");
66+
LOGGER.info("Found mods:");
6567
for (ModInfo mod : mods) {
66-
Logger.info(" - " + mod.toString(), "Loader");
68+
LOGGER.info(" - {}", mod.toString());
6769
}
6870
}
6971
}
@@ -166,7 +168,7 @@ static class MixinTransformer implements ClassFileTransformer {
166168
public byte[] transform(ClassLoader l, String className, Class<?> c,
167169
ProtectionDomain d, byte[] buffer) {
168170
if (!injectionPoints.containsKey(className)) return null;
169-
Logger.debug("Loading " + className + ", loader: " + l.getName(), this);
171+
LOGGER.info("Loading {}, loader: {}", className, l.getName());
170172
ClassReader cr = new ClassReader(buffer);
171173
ClassWriter cw = new ClassWriter(cr, ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
172174
cr.accept(new InjectionClassVisitor(cw, className), 0);
@@ -191,8 +193,7 @@ public MethodVisitor visitMethod(int access, String name, String desc,
191193
for (InjectionPoint point : points) {
192194
if (point.inject.method().equals(name) &&
193195
(point.inject.descriptor().isEmpty() || point.inject.descriptor().equals(desc))) {
194-
Logger.debug("Transforming " + name + desc +
195-
", handler: " + point.handlerClass + "." + point.handlerMethod, this);
196+
LOGGER.info("transforming {}", name + desc);
196197
mv = new InjectionMethodVisitor(mv, access, desc, point, this.className);
197198
}
198199
}
@@ -262,8 +263,7 @@ void injectHelper() {
262263
}
263264
}
264265

265-
static void generateHelperCall(MethodVisitor mv, int access, String desc, InjectionPoint injection,
266-
String className) {
266+
static void generateHelperCall(MethodVisitor mv, int access, String desc, InjectionPoint injection, String className) {
267267
boolean isStatic = (access & Opcodes.ACC_STATIC) != 0;
268268

269269
mv.visitTypeInsn(Opcodes.NEW, "io/github/freehij/loader/util/InjectionHelper");

src/main/java/io/github/freehij/loader/util/Logger.java

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)