Enable use of FML's unused TracingPrintStream for tracking mod messages on System.out

We implement this ourselves because we need it on 1.20.1 anyway,
it will eventually be implemented upstream in NeoForge, at
which point this feature will be removed:
https://github.com/neoforged/FancyModLoader/issues/277
This commit is contained in:
embeddedt 2025-04-29 11:14:26 -04:00
parent 9be6134073
commit ae729bcd15
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 8 additions and 0 deletions

View File

@ -182,6 +182,7 @@ public class ModernFixEarlyConfig {
.put("mixin.feature.snapshot_easter_egg", true)
.put("mixin.feature.warn_missing_perf_mods", true)
.put("mixin.feature.spark_profile_launch", false)
.put("mixin.feature.log_stdout_in_log_files", true)
.put("mixin.devenv", isDevEnv)
.put("mixin.perf.remove_spawn_chunks", isDevEnv)
.putConditionally(() -> !isFabric, "mixin.bugfix.fix_config_crashes", true)

View File

@ -17,6 +17,7 @@ import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.fml.loading.FMLLoader;
import net.minecraftforge.fml.loading.FMLPaths;
import net.minecraftforge.fml.loading.LoadingModList;
import net.minecraftforge.fml.loading.TracingPrintStream;
import net.minecraftforge.fml.loading.moddiscovery.ModInfo;
import net.minecraftforge.network.PacketDistributor;
import net.minecraftforge.server.ServerLifecycleHooks;
@ -33,6 +34,7 @@ import org.embeddedt.modernfix.spark.SparkLaunchProfiler;
import org.embeddedt.modernfix.util.CommonModUtil;
import org.embeddedt.modernfix.util.DummyList;
import org.objectweb.asm.tree.ClassNode;
import org.slf4j.LoggerFactory;
import org.spongepowered.asm.mixin.injection.struct.InjectorGroupInfo;
import java.lang.reflect.Field;
@ -112,6 +114,11 @@ public class ModernFixPlatformHooksImpl implements ModernFixPlatformHooks {
CommonModUtil.runWithoutCrash(() -> SparkLaunchProfiler.start("launch"), "Failed to start profiler");
}
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.log_stdout_in_log_files.PrintStreamReplacement")) {
System.setOut(new TracingPrintStream(LoggerFactory.getLogger("STDOUT"), System.out));
System.setErr(new TracingPrintStream(LoggerFactory.getLogger("STDERR"), System.err));
}
NightConfigFixer.monitorFileWatcher();
NightConfigWatchThrottler.throttle();
}