-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogManager.cs
48 lines (44 loc) · 1.26 KB
/
LogManager.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
using System;
using System.IO;
using static TunnelMonitor.MainWindow;
namespace TunnelMonitor
{
public class LogManager
{
private static string logDirectoryPath = @"C:\TunnelMonitor\";
private static string logFileName = "tunnel.log";
public LogManager(
string path = ""
)
{
logDirectoryPath = path;
}
// Log en persons indgang til tunnelen
public string LogPath
{
get => logDirectoryPath;
set
{
logDirectoryPath = value;
logFileName = "tunnel.log";
}
}
public void LogEntry(PersonEntry entry)
{
string entryLog = $"ENTRY: {entry.ToString()}";
File.AppendAllText(
Path.Combine(logDirectoryPath, logFileName),
entryLog + Environment.NewLine
);
}
// Log en persons udgang fra tunnelen og tilføj til historik
public void LogExit(PersonEntry entry)
{
string exitLog = $"EXIT: {entry.ToString()}";
File.AppendAllText(
Path.Combine(logDirectoryPath, logFileName),
exitLog + Environment.NewLine
);
}
}
}