diff --git a/IPA.Injector/Injector.cs b/IPA.Injector/Injector.cs index 523e869c..acfbe4a2 100644 --- a/IPA.Injector/Injector.cs +++ b/IPA.Injector/Injector.cs @@ -312,7 +312,7 @@ namespace IPA.Injector UnityLogProvider.UnityLogger.Log(level, $"{stackTrace}"); }; - ConfigureHarmonyLogging(); + StdoutInterceptor.EnsureHarmonyLogging(); // need to reinit streams singe Unity seems to redirect stdout StdoutInterceptor.RedirectConsole(); diff --git a/IPA.Loader/Logging/StdoutInterceptor.cs b/IPA.Loader/Logging/StdoutInterceptor.cs index 9d83851c..26d14fe9 100644 --- a/IPA.Loader/Logging/StdoutInterceptor.cs +++ b/IPA.Loader/Logging/StdoutInterceptor.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection.Emit; using System.Text; +using System.Threading; using static IPA.Logging.Logger; namespace IPA.Logging @@ -189,7 +190,7 @@ namespace IPA.Logging { usingInterceptor = true; - ConfigureHarmonyLogging(); + EnsureHarmonyLogging(); harmony ??= new Harmony("BSIPA Console Redirector Patcher"); stdoutInterceptor ??= new StdoutInterceptor(); @@ -209,17 +210,21 @@ namespace IPA.Logging } } + private static int harmonyLoggingInited; // I'm not completely sure this is the best place for this, but whatever - private static void ConfigureHarmonyLogging() + internal static void EnsureHarmonyLogging() { + if (Interlocked.Exchange(ref harmonyLoggingInited, 1) != 0) + return; + HarmonyLib.Tools.Logger.ChannelFilter = HarmonyLib.Tools.Logger.LogChannel.All & ~HarmonyLib.Tools.Logger.LogChannel.IL; HarmonyLib.Tools.Logger.MessageReceived += (s, e) => { var msg = e.Message; var lvl = e.LogChannel switch { - HarmonyLib.Tools.Logger.LogChannel.None => Level.Info, - HarmonyLib.Tools.Logger.LogChannel.Info => Level.Info, + HarmonyLib.Tools.Logger.LogChannel.None => Level.Notice, + HarmonyLib.Tools.Logger.LogChannel.Info => Level.Trace, // HarmonyX logs a *lot* of Info messages HarmonyLib.Tools.Logger.LogChannel.IL => Level.Trace, HarmonyLib.Tools.Logger.LogChannel.Warn => Level.Warning, HarmonyLib.Tools.Logger.LogChannel.Error => Level.Error,