From a70dd6edcb055672123c65e131e00d8e8a221e7c Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Sun, 2 Sep 2018 15:21:29 -0500 Subject: [PATCH] Tweaked some stuff regarding the loader and loggers --- IPA.Injector/Bootstrapper.cs | 2 +- IPA.Injector/ConsoleWindow.cs | 2 +- IPA.Loader/Logging/Logger.cs | 2 +- IPA.Loader/Logging/StandardLogger.cs | 4 +--- IPA.Loader/Logging/UnityLogInterceptor.cs | 10 +++++++++- IPA.Loader/ModPrefs.cs | 3 ++- 6 files changed, 15 insertions(+), 8 deletions(-) diff --git a/IPA.Injector/Bootstrapper.cs b/IPA.Injector/Bootstrapper.cs index 1d0f2261..0f8e6cd2 100644 --- a/IPA.Injector/Bootstrapper.cs +++ b/IPA.Injector/Bootstrapper.cs @@ -14,7 +14,7 @@ namespace IPA.Injector { //if (Environment.CommandLine.Contains("--verbose")) //{ - Ipa.Injector.Windows.WinConsole.Initialize(); + Windows.WinConsole.Initialize(); //} } diff --git a/IPA.Injector/ConsoleWindow.cs b/IPA.Injector/ConsoleWindow.cs index e854ed27..96fb1365 100644 --- a/IPA.Injector/ConsoleWindow.cs +++ b/IPA.Injector/ConsoleWindow.cs @@ -5,7 +5,7 @@ using System.IO; using System.Text; using Microsoft.Win32.SafeHandles; -namespace Ipa.Injector.Windows +namespace IPA.Injector.Windows { // https://stackoverflow.com/a/48864902/3117125 static class WinConsole diff --git a/IPA.Loader/Logging/Logger.cs b/IPA.Loader/Logging/Logger.cs index aa9d8004..70bf4016 100644 --- a/IPA.Loader/Logging/Logger.cs +++ b/IPA.Loader/Logging/Logger.cs @@ -24,7 +24,7 @@ namespace IPA.Logging internal static Logger updater => log.GetChildLogger("Updater"); internal static Logger libLoader => log.GetChildLogger("LibraryLoader"); internal static Logger loader => log.GetChildLogger("Loader"); - internal static bool LogCreated => _log != null; + internal static bool LogCreated => _log != null || UnityLogInterceptor._logger != null; /// /// The standard format for log messages. diff --git a/IPA.Loader/Logging/StandardLogger.cs b/IPA.Loader/Logging/StandardLogger.cs index 3799f4c7..e3706fc0 100644 --- a/IPA.Loader/Logging/StandardLogger.cs +++ b/IPA.Loader/Logging/StandardLogger.cs @@ -52,15 +52,13 @@ namespace IPA.Logging /// /// All levels defined by this filter will be sent to loggers. All others will be ignored. /// - public static LogLevel PrintFilter { get; set; } = LogLevel.InfoUp; + public static LogLevel PrintFilter { get; set; } = ModPrefs.GetBool("IPA", "PrintDebug", false, true) ? LogLevel.All : LogLevel.InfoUp; private List printers = new List(defaultPrinters); private Dictionary children = new Dictionary(); static StandardLogger() { - if (ModPrefs.GetBool("IPA", "PrintDebug", false, true)) - PrintFilter = LogLevel.All; showSourceClass = ModPrefs.GetBool("IPA", "DebugShowCallSource", false, true); } diff --git a/IPA.Loader/Logging/UnityLogInterceptor.cs b/IPA.Loader/Logging/UnityLogInterceptor.cs index 908f11bf..6b9d0fe3 100644 --- a/IPA.Loader/Logging/UnityLogInterceptor.cs +++ b/IPA.Loader/Logging/UnityLogInterceptor.cs @@ -9,7 +9,15 @@ namespace IPA.Logging { internal class UnityLogInterceptor { - public static Logger UnityLogger = new StandardLogger("UnityEngine"); + internal static Logger _logger; + public static Logger UnityLogger { + get + { + if (_logger == null) + _logger = new StandardLogger("UnityEngine"); + return _logger; + } + } public static Logger.Level LogTypeToLevel(LogType type) { diff --git a/IPA.Loader/ModPrefs.cs b/IPA.Loader/ModPrefs.cs index 3657a81d..b5a033d4 100644 --- a/IPA.Loader/ModPrefs.cs +++ b/IPA.Loader/ModPrefs.cs @@ -186,7 +186,8 @@ namespace IPA if (sVal == "1" || sVal == "0") { return sVal == "1"; - } else if (autoSave) + } + else if (autoSave) { (this as IModPrefs).SetBool(section, name, defaultValue); }