aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/src/Godosa.Core/Diagnostics/EngineDebug.cs
blob: 3cad8197b036b56065eca4993f307a8b48af81b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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}");
}