-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathApmLogger.cs
62 lines (51 loc) · 1.56 KB
/
ApmLogger.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
using System;
using System.Diagnostics;
using Colossal.Logging;
using Colossal.PSI.Environment;
namespace AssetPacksManager;
public class ApmLogger
{
private static readonly string logFileName = $"{nameof(AssetPacksManager)}.{nameof(Mod)}";
public static readonly ILog Logger = LogManager.GetLogger(logFileName)
.SetShowsErrorsInUI(false);
public static ApmLogger Instance;
private static readonly bool DisableLogging = false;
public static void Init()
{
Instance = new ApmLogger();
}
public void OpenLogFile()
{
Process.Start($"{EnvPath.kUserDataPath}/Logs/{logFileName}.log");
}
public void Debug(string message)
{
if (DisableLogging || Setting.Instance.LoggingLevel > Setting.LogLevel.Debug)
return;
Logger.Debug(message);
}
public void Info(string message)
{
if (DisableLogging || Setting.Instance.LoggingLevel > Setting.LogLevel.Info)
return;
Logger.Info(message);
}
public void Warn(string message)
{
if (DisableLogging || Setting.Instance.LoggingLevel > Setting.LogLevel.Warning)
return;
Logger.Warn(message);
}
public void Error(string message)
{
if (DisableLogging || Setting.Instance.LoggingLevel > Setting.LogLevel.Error)
return;
Logger.Error(message);
}
public void Critical(string message)
{
if (DisableLogging || Setting.Instance.LoggingLevel > Setting.LogLevel.Critical)
return;
Logger.Critical(message);
}
}