forked from TBSniller/cmpinf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.cs
More file actions
27 lines (27 loc) · 857 Bytes
/
Log.cs
File metadata and controls
27 lines (27 loc) · 857 Bytes
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
26
27
public static class Log
{
public static bool Verbose { get; set; } = false;
public static event Action<string, string>? OnLog;
public static void Debug(string msg)
{
if (Verbose)
{
var line = $"[DEBUG] {msg}";
try { Console.WriteLine(line); } catch { /* ignore */ }
var singleLine = line.Replace("\r\n", "").Replace("\n", "").Replace("\r", "");
OnLog?.Invoke("DEBUG", singleLine);
}
}
public static void Info(string msg)
{
var line = $"[INFO] {msg}";
try { Console.WriteLine(line); } catch { /* ignore */ }
OnLog?.Invoke("INFO", line);
}
public static void Warn(string msg)
{
var line = $"[WARN] {msg}";
try { Console.WriteLine(line); } catch { /* ignore */ }
OnLog?.Invoke("WARN", line);
}
}