-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathLogger.cs
More file actions
34 lines (29 loc) · 742 Bytes
/
Logger.cs
File metadata and controls
34 lines (29 loc) · 742 Bytes
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
using System;
using System.IO;
namespace ServerScan
{
class Logger
{
private const String fileName = "log.txt";
private static bool firstLine = true;
private static StreamWriter log;
public static void Log(String str)
{
if (!File.Exists(fileName))
{
log = new StreamWriter(fileName);
}
else
{
log = File.AppendText(fileName);
}
if (firstLine)
{
log.WriteLine();
firstLine = false;
}
log.WriteLine(DateTime.Now + ": " + str);
log.Close();
}
}
}