forked from KSP-ModularManagement/ModuleManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModLogger.cs
More file actions
40 lines (35 loc) · 1.39 KB
/
Copy pathModLogger.cs
File metadata and controls
40 lines (35 loc) · 1.39 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
using System;
using UnityEngine;
using K = KSPe.Util.Log;
namespace ModuleManager.Logging
{
public class ModLogger : IBasicLogger
{
internal static readonly K.Logger LOG = K.Logger.CreateThreadUnsafeForType<ModuleManager>(); // No need to use thread safe logging. Yet.
internal static readonly ModLogger Instance = new ModLogger(); // For legacy code
private delegate void LogMethod(string message, params object[] @parms);
private readonly LogMethod[] methods;
private ModLogger()
{
this.methods = new LogMethod[6];
int i = 0;
this.methods[i++] = new LogMethod(LOG.error);
this.methods[i++] = new LogMethod(LOG.error);
this.methods[i++] = new LogMethod(LOG.warn);
this.methods[i++] = new LogMethod(LOG.info);
this.methods[i++] = new LogMethod(LOG.detail);
this.methods[i++] = new LogMethod(LOG.error);
LOG.level = K.Level.TRACE;
}
// Gambiarra porque eu não previ essa possibilidade no KSPe.Util.Log!
private static readonly object[] NONE = new object[0];
public void Log(LogType logType, string message)
{
this.methods[(int)logType](message, NONE);
}
public void Exception(string message, Exception exception)
{
LOG.error(exception, message);
}
}
}