Skip to content

Commit cbf8a34

Browse files
committed
[DEBUG] Silence out some spammy debug log
In addition, move the critical internal data of the mod into a dedicated class of its own
1 parent 08e2c9f commit cbf8a34

File tree

6 files changed

+72
-20
lines changed

6 files changed

+72
-20
lines changed

COTLMP/Api/Localization.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,8 @@ public static void Add(string Language, string Term, string Translation, bool Ov
176176
}
177177

178178
/* Add the string */
179-
#if DEBUG
180-
COTLMP.Debug.PrintLogger.Print(DebugLevel.INFO_LEVEL, DebugComponent.LOCALIZATION_COMPONENT,
181-
$"Adding {Translation} translation from {Term} term for {Language} language!");
182-
#endif
179+
COTLMP.Debug.PrintLogger.PrintVerbose(DebugLevel.INFO_LEVEL, DebugComponent.LOCALIZATION_COMPONENT,
180+
$"Adding {Translation} translation from {Term} term for {Language} language!");
183181
Translations[Language][Term] = Translation;
184182
}
185183

@@ -199,10 +197,8 @@ public static void Remove(string Language, string Term)
199197
if (!Translations.ContainsKey(Language)) return;
200198

201199
/* Remove the translated string */
202-
#if DEBUG
203-
COTLMP.Debug.PrintLogger.Print(DebugLevel.INFO_LEVEL, DebugComponent.LOCALIZATION_COMPONENT,
204-
$"Removing {Term} term from {Language} language!");
205-
#endif
200+
COTLMP.Debug.PrintLogger.PrintVerbose(DebugLevel.INFO_LEVEL, DebugComponent.LOCALIZATION_COMPONENT,
201+
$"Removing {Term} term from {Language} language!");
206202
Translations[Language].Remove(Term);
207203
}
208204

COTLMP/Data/InternalData.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* PROJECT: Cult of the Lamb Multiplayer Mod
3+
* LICENSE: MIT (https://spdx.org/licenses/MIT)
4+
* PURPOSE: Internal data and flag switches of the mod
5+
* COPYRIGHT: Copyright 2025 GeoB99 <[email protected]>
6+
*/
7+
8+
/* IMPORTS ********************************************************************/
9+
10+
using COTLMP;
11+
12+
/* CLASSES & CODE *************************************************************/
13+
14+
/*
15+
* @brief
16+
* Contains internal global mod data, reserved for developers only.
17+
*
18+
* @class InternalData
19+
* Main class of which mod data is stored.
20+
*/
21+
namespace COTLMP.Data
22+
{
23+
internal class InternalData
24+
{
25+
/******************************************************************************
26+
* THE FOLLOWING FIELDS ARE RESERVED INTERNALLY *
27+
* FOR THE MOD. CHANGE THESE VALUES WITH CAUTION!!! *
28+
******************************************************************************/
29+
30+
/* Enable or disable verbose debug output in the console */
31+
internal bool VerboseDebug = false;
32+
33+
/* The internal variable of maximum count of players per server. Used for validation purposes. */
34+
internal const int MaxPlayersPerServerInternal = 8;
35+
36+
internal InternalData()
37+
{
38+
/* Do nothing */
39+
}
40+
}
41+
}
42+
43+
/* EOF */

COTLMP/Data/ModDataGlobals.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,6 @@ internal class ModDataGlobals
4040
/* Enable or Disable voice chat */
4141
public bool EnableVoiceChat;
4242

43-
/******************************************************************************
44-
* THE FOLLOWING FIELDS ARE RESERVED INTERNALLY *
45-
* FOR THE MOD. CHANGE THESE VALUES WITH CAUTION!!! *
46-
******************************************************************************/
47-
48-
/* Enable or disable verbose debug output in the console */
49-
internal bool VerboseDebug = false;
50-
51-
/* The internal variable of maximum count of players per server. Used for validation purposes. */
52-
internal const int MaxPlayersPerServerInternal = 8;
53-
5443
public ModDataGlobals(bool Enable,
5544
string Mode,
5645
string PlName,

COTLMP/Debug/PrintLogger.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,26 @@ public static void Print(DebugLevel Level, DebugComponent Component, string Text
236236
}
237237
}
238238
}
239+
240+
/*
241+
* @brief
242+
* Prints debug information to the logger. Works identically
243+
* the same to the Print method except that this method is
244+
* reserved for debug output that might be too spammy in
245+
* the debug console. If the VerboseDebug flag is set to FALSE
246+
* this method won't output anything to the console.
247+
*/
248+
public static void PrintVerbose(DebugLevel Level, DebugComponent Component, string Text)
249+
{
250+
/* Don't display anything if verbose debugging is disabled */
251+
if (!Plugin.GlobalsInternal.VerboseDebug)
252+
{
253+
return;
254+
}
255+
256+
/* Output the spammy debug log */
257+
Print(Level, Component, Text);
258+
}
239259
}
240260
}
241261

COTLMP/Plugin.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class Plugin : BaseUnityPlugin
4141
internal static new ManualLogSource Logger;
4242
internal static new ConfigFile Config;
4343
internal static ModDataGlobals Globals;
44+
internal static InternalData GlobalsInternal;
4445

4546
/*
4647
* @brief
@@ -61,6 +62,9 @@ private void Awake()
6162
Logger = base.Logger;
6263
Config = base.Config;
6364

65+
/* Fetch the flags and switches of the mod, reserved for internal use */
66+
GlobalsInternal = new InternalData();
67+
6468
/* Load the localizations of the mod */
6569
COTLMP.Api.Localization.LoadLocale("English");
6670

COTLMP/Ui/MainMenu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ internal static class MainMenuPatches
5656
private static bool OnMultiplayerButtonClickedPatch(MainMenu __instance)
5757
{
5858
/* Throw a dialog box warning the user Multiplayer is currently WIP */
59-
COTLMP.Debug.PrintLogger.Print(DebugLevel.INFO_LEVEL, DebugComponent.UI_COMPONENT, "The Multiplayer button has been clicked!");
59+
COTLMP.Debug.PrintLogger.Print(DebugLevel.MESSAGE_LEVEL, DebugComponent.UI_COMPONENT, "The Multiplayer button has been clicked!");
6060
UIMenuConfirmationWindow ConfirmDialog = __instance.Push<UIMenuConfirmationWindow>(MonoSingleton<UIManager>.Instance.ConfirmationWindowTemplate);
6161
ConfirmDialog.Configure(MultiplayerModLocalization.UI.Multiplayer_Title, MultiplayerModLocalization.UI.Multiplayer_Text, true);
6262
return false;

0 commit comments

Comments
 (0)