blob: 27b63bfdb9ccaef77a12c2bd3a474f2ccc219f59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
namespace Godosa.Core.Diagnostics;
/// <summary>Opt-in debug categories from one environment value: a comma list,
/// case-insensitive; <c>all</c> turns on every category but not <see cref="Exact"/>
/// switches (perf experiments like <c>nohud</c>).</summary>
public sealed class DebugFlags
{
private readonly string[] _names;
public DebugFlags(string? value) =>
_names = (value ?? "").Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
public bool On(string category) =>
Array.Exists(_names, n =>
n.Equals(category, StringComparison.OrdinalIgnoreCase) ||
n.Equals("all", StringComparison.OrdinalIgnoreCase));
public bool Exact(string name) =>
Array.Exists(_names, n => n.Equals(name, StringComparison.OrdinalIgnoreCase));
}
|