From ae729bcd151585adcafaf422a436470d9ef50613 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 29 Apr 2025 11:14:26 -0400 Subject: [PATCH] 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 --- .../modernfix/core/config/ModernFixEarlyConfig.java | 1 + .../platform/forge/ModernFixPlatformHooksImpl.java | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java index c92f0907..b488e4c0 100644 --- a/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java +++ b/common/src/main/java/org/embeddedt/modernfix/core/config/ModernFixEarlyConfig.java @@ -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) diff --git a/forge/src/main/java/org/embeddedt/modernfix/platform/forge/ModernFixPlatformHooksImpl.java b/forge/src/main/java/org/embeddedt/modernfix/platform/forge/ModernFixPlatformHooksImpl.java index bfef2132..dbf8edf9 100644 --- a/forge/src/main/java/org/embeddedt/modernfix/platform/forge/ModernFixPlatformHooksImpl.java +++ b/forge/src/main/java/org/embeddedt/modernfix/platform/forge/ModernFixPlatformHooksImpl.java @@ -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(); }