-
Notifications
You must be signed in to change notification settings - Fork 8
/
DebugLog.cs
39 lines (35 loc) · 959 Bytes
/
DebugLog.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
using System;
using System.IO;
using System.Net.Http.Headers;
using System.Threading;
namespace ClubmanSharp
{
public class DebugLog
{
public static bool isActive = false;
private readonly static string path = Path.Combine(Directory.GetCurrentDirectory(), "debug.log");
public static void SetActive(bool state)
{
isActive = state;
}
public static void Log(string msg)
{
if (!isActive)
return;
byte retryCount = 0;
while (retryCount < 10)
{
try
{
File.AppendAllText(path, $"[{DateTime.Now:yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffff}] {msg}\n");
break;
}
catch (IOException)
{
Thread.Sleep(100);
retryCount++;
}
}
}
}
}