-
Notifications
You must be signed in to change notification settings - Fork 2
/
log.cs
43 lines (38 loc) · 997 Bytes
/
log.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
using System.Text;
namespace TASI
{
internal class Logger
{
public string? path;
public bool loggerEnabled = true;
private StreamWriter? logWriter;
public Logger(string path)
{
if (File.Exists(path))
File.Delete(path);
this.path = path;
logWriter = new StreamWriter(path, true, Encoding.UTF8, 100000);
}
public Logger()
{
loggerEnabled = false;
}
public void Log(string content)
{
if (loggerEnabled)
{
if (logWriter == null)
{
if (File.Exists(path))
File.Delete(path);
logWriter = new StreamWriter(path, true, Encoding.UTF8, 100000);
}
logWriter.WriteLine(content);
}
}
public void Flush()
{
logWriter.Flush();
}
}
}