-
Notifications
You must be signed in to change notification settings - Fork 4
/
Logging.cs
65 lines (55 loc) · 1.67 KB
/
Logging.cs
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static UnityModManagerNet.UnityModManager.ModEntry;
namespace MoreCantrips
{
internal static class Logging
{
private const string BaseChannel = "MoreCantrips";
private static readonly Dictionary<string, Logger> Loggers = new();
private static bool VerboseLogging = false;
internal static Logger GetLogger(string channel)
{
if (Loggers.ContainsKey(channel))
{
return Loggers[channel];
}
var logger = new Logger($"{BaseChannel}+{channel}");
Loggers[channel] = logger;
return logger;
}
internal static void EnableVerboseLogging(bool enabled)
{
VerboseLogging = enabled;
BlueprintCore.Utils.LogWrapper.EnableInternalVerboseLogs(enabled);
}
internal class Logger
{
private readonly ModLogger InternalLog;
internal Logger(string name)
{
InternalLog = new(name);
}
internal void Log(string str)
{
InternalLog.Log(str);
}
internal void Warning(string str)
{
InternalLog.Warning(str);
}
internal void LogException(string key, Exception e)
{
InternalLog.LogException(key, e);
}
internal void Verbose(string str)
{
if (VerboseLogging)
InternalLog.NativeLog(str);
}
}
}
}