-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLog.cs
More file actions
44 lines (34 loc) · 1.05 KB
/
Copy pathLog.cs
File metadata and controls
44 lines (34 loc) · 1.05 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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProcessesMonitoring
{
public static class Log
{
private static string logPath;
private static CultureInfo culture;
public static void Start(string filename_)
{
logPath = Path.Combine(Directory.GetCurrentDirectory(), filename_);
culture = new CultureInfo("en-GB");
}
public static async Task Write(string message)
{
string text = String.Format("{0}", message);
using (FileStream sourceStream = new FileStream(logPath,
FileMode.Append, FileAccess.Write, FileShare.None,
bufferSize: 4096, useAsync: true))
{
using (StreamWriter sw = new StreamWriter(sourceStream))
{
await sw.WriteLineAsync(text);
}
};
}
}
}