From 9d528245e2192fd7a9bb7bac7d88abd0d4ce083b Mon Sep 17 00:00:00 2001 From: Kinsi Date: Sat, 16 Jul 2022 23:33:14 +0200 Subject: [PATCH] Added --no-logs launch argument --- IPA.Loader/Config/SelfConfig.cs | 6 ++++++ IPA.Loader/Logging/StandardLogger.cs | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/IPA.Loader/Config/SelfConfig.cs b/IPA.Loader/Config/SelfConfig.cs index 451627fb..433ac088 100644 --- a/IPA.Loader/Config/SelfConfig.cs +++ b/IPA.Loader/Config/SelfConfig.cs @@ -53,6 +53,9 @@ namespace IPA.Config case "--no-yeet": CommandLineValues.YeetMods = false; break; + case "--no-logs": + CommandLineValues.WriteLogs = true; + break; case "--condense-logs": CommandLineValues.Debug.CondenseModLogs = true; break; @@ -174,6 +177,9 @@ namespace IPA.Config public static bool YeetMods_ => (Instance?.YeetMods ?? true) && CommandLineValues.YeetMods; + [JsonIgnore] + public bool WriteLogs { get; set; } = true; + // LINE: ignore [NonNullable, UseConverter(typeof(CollectionConverter>))] public virtual HashSet GameAssemblies { get; set; } = new HashSet diff --git a/IPA.Loader/Logging/StandardLogger.cs b/IPA.Loader/Logging/StandardLogger.cs index 72a5b3c3..50bb727b 100644 --- a/IPA.Loader/Logging/StandardLogger.cs +++ b/IPA.Loader/Logging/StandardLogger.cs @@ -25,10 +25,7 @@ namespace IPA.Logging /// public class StandardLogger : Logger { - private static readonly List defaultPrinters = new() - { - new GlobalLogFilePrinter() - }; + private static readonly List defaultPrinters = new(); static StandardLogger() { @@ -115,6 +112,7 @@ namespace IPA.Logging private readonly Dictionary children = new(); + private static bool addedFilePrinter = false; /// /// Configures internal debug settings based on the config passed in. /// @@ -124,6 +122,10 @@ namespace IPA.Logging PrintFilter = SelfConfig.Debug_.ShowDebug_ ? LogLevel.All : LogLevel.InfoUp; showTrace = SelfConfig.Debug_.ShowTrace_; syncLogging = SelfConfig.Debug_.SyncLogging_; + if(SelfConfig.CommandLineValues.WriteLogs && !addedFilePrinter) { + addedFilePrinter = true; + AddDefaultPrinter(new GZFilePrinter()); + } } private StandardLogger(StandardLogger parent, string subName)