Skip to content

Commit 6e0d2c2

Browse files
committed
Preventing dumping the MMLog into KSP.log when not loading from cache (the information is already on the log, no need for duplicated information!)
1 parent 81c88b4 commit 6e0d2c2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Source/ModuleManager/Logging/ModLogger.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class ModLogger : IBasicLogger
99
{
1010
internal static readonly K.Logger LOG = K.Logger.CreateThreadUnsafeForType<ModuleManager>(); // No need to use thread safe logging. Yet.
1111
internal static readonly ModLogger Instance = new ModLogger(); // For legacy code
12+
internal static bool DebugMode => KSPe.Globals<ModuleManager>.DebugMode;
1213

1314
private delegate void LogMethod(string message, params object[] @parms);
1415
private readonly LogMethod[] methods;

Source/ModuleManager/MMPatchLoader.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,14 @@ public IEnumerable<IProtoUrlConfig> Run()
198198
// But...
199199
// Now I see the reason this was done this way. Asking the user to send KSP.log is tricky by itself, and
200200
// sending more than one log is yet more troublesome.
201-
// What I can do is to only dump this on KSP.log when the KSPe.Util.Log.Level is bigger than Info.
201+
// What I can do is to only dump this on KSP.log when the the KSPe Globals for ModuleManager has Debug set to true.
202202
// (the default KSPe's Global for Module Manager as from KSPe 2.2.3)
203203
string patchLogPath = KSPe.IO.File<Startup>.Data.Solve(FilePathRepository.PATCH_LOG_FILENAME + ".log");
204204
if (File.Exists(patchLogPath))
205205
{
206-
if (ModLogger.LOG.level > KSPe.Util.Log.Level.INFO)
206+
#pragma warning disable CS0618 // Type or member is obsolete
207+
if (ModuleManager.IsLoadedFromCache && ModLogger.DebugMode)
208+
#pragma warning restore CS0618 // Type or member is obsolete
207209
{
208210
logger.Info("Dumping patch log");
209211
logger.Info("\n#### BEGIN PATCH LOG ####\n\n\n" + File.ReadAllText(patchLogPath) + "\n\n\n#### END PATCH LOG ####");

0 commit comments

Comments
 (0)