-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.cs
More file actions
33 lines (29 loc) · 730 Bytes
/
Copy pathLogger.cs
File metadata and controls
33 lines (29 loc) · 730 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace PaxtonSync
{
public class Logger
{
// A bit dirty having all this static - but probably OK given the use.
private static TextWriter _logFile;
static Logger()
{
var fileName = "PaxtonSyncLog-" + DateTime.UtcNow.ToString("yyyy-MM-dd-HH-mm") + ".log";
_logFile = new StreamWriter(File.OpenWrite(fileName));
}
~Logger()
{
_logFile.Dispose();
}
public static void WriteLine(string format, params object[] args)
{
format = DateTime.UtcNow.ToString("s") + ": " + format;
Console.WriteLine(format, args);
_logFile.WriteLine(format, args);
}
}
}