aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/src/Godosa.Core/Diagnostics/EngineDebug.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Godosa.Core/Diagnostics/EngineDebug.cs')
-rw-r--r--src/Godosa.Core/Diagnostics/EngineDebug.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Godosa.Core/Diagnostics/EngineDebug.cs b/src/Godosa.Core/Diagnostics/EngineDebug.cs
new file mode 100644
index 0000000..3cad819
--- /dev/null
+++ b/src/Godosa.Core/Diagnostics/EngineDebug.cs
@@ -0,0 +1,25 @@
+namespace Godosa.Core.Diagnostics;
+
+/// <summary>The lib's own debug categories (<c>input</c>, <c>script</c>, <c>audio</c>), read
+/// from the game's variable: call <see cref="Configure"/> first in <c>Main</c>, before any lib
+/// code runs. Gate each call on its flag so disabled logging costs one bool check and no
+/// string formatting.</summary>
+public static class EngineDebug
+{
+ public static bool Input { get; private set; }
+ public static bool Script { get; private set; }
+ public static bool Audio { get; private set; }
+
+ public static void Configure(string environmentVariable) =>
+ Apply(new DebugFlags(Environment.GetEnvironmentVariable(environmentVariable)));
+
+ public static void Apply(DebugFlags flags)
+ {
+ Input = flags.On("input");
+ Script = flags.On("script");
+ Audio = flags.On("audio");
+ }
+
+ public static void Write(string category, string message) =>
+ Console.Error.WriteLine($"[{category}] {message}");
+}