-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathLog.cs
More file actions
46 lines (39 loc) · 1.25 KB
/
Log.cs
File metadata and controls
46 lines (39 loc) · 1.25 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
using System;
using System.Collections.Generic;
using BepInEx.Logging;
namespace Bulldozer
{
public class Log
{
public static ManualLogSource logger;
public static void LogAndPopupMessage(string message, bool playSound = false)
{
UIRealtimeTip.Popup(message, playSound);
logger.LogWarning($"Popped up message {message}");
}
public static void Debug(string message)
{
logger.LogDebug($"[{DateTime.Now:HH:mm:ss.fff}] {message}");
}
public static void Warn(string message)
{
logger.LogWarning($"[{DateTime.Now:HH:mm:ss.fff}] {message}");
}
private static Dictionary<string, int> _logCount = new ();
public static void LogNTimes(string msg, int maxTimes, params object[] args)
{
if (!_logCount.ContainsKey(msg) || maxTimes < 0)
_logCount[msg] = 0;
else if (_logCount[msg] > maxTimes)
return;
_logCount[msg]++;
Debug(string.Format(msg, args));
}
public static void Trace(string msg)
{
#if DEBUG
logger.LogInfo($"[{DateTime.Now:HH:mm:ss.fff}] {msg}");
#endif
}
}
}