-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbyssLogger.cs
More file actions
63 lines (53 loc) · 1.5 KB
/
AbyssLogger.cs
File metadata and controls
63 lines (53 loc) · 1.5 KB
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
using static Abyss.Utilities.AbyssUtils;
namespace Abyss;
/// <summary>
/// Allows for easy logging from anywhere in the mod, using the mod's plugin type
/// </summary>
public static class AbyssLogger
{
/// <inheritdoc cref="Info{T}"/>
public static void Log<T>(object? obj) where T : DredgeMod => Info<T>(obj);
/// <summary>
/// Logs an info message from the specified Mod's Logger
/// </summary>
public static void Info<T>(object? obj) where T : DredgeMod
{
GetMod<T>().Logger.LogInfo(obj ?? "null");
}
/// <summary>
/// Logs an error message from the specified Mod's Logger
/// </summary>
public static void Error<T>(object? obj) where T : DredgeMod
{
GetMod<T>().Logger.LogError(obj ?? "null");
}
/// <summary>
/// Logs a warning message from the specified Mod's Logger
/// </summary>
public static void Warning<T>(object? obj) where T : DredgeMod
{
GetMod<T>().Logger.LogWarning(obj ?? "null");
}
internal static void Log(object? obj) => Info(obj);
internal static void Info(object? obj)
{
lock (Main.Logger)
{
Main.Logger.LogInfo(obj ?? "null");
}
}
internal static void Error(object? obj)
{
lock (Main.Logger)
{
Main.Logger.LogError(obj ?? "null");
}
}
internal static void Warning(object? obj)
{
lock (Main.Logger)
{
Main.Logger.LogWarning(obj ?? "null");
}
}
}