-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSimpleLogger.cs
43 lines (35 loc) · 915 Bytes
/
SimpleLogger.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
#region
using System;
using System.Globalization;
using System.IO;
using System.Text;
using System.Web;
#endregion
namespace EppLib
{
internal class SimpleLogger : IDebugger
{
public static string LogFilename = Path.Combine(HttpRuntime.AppDomainAppPath, "bin\\epplog.txt");
public void Log(byte[] bytes)
{
LogMessageToFile(Encoding.UTF8.GetString(bytes));
}
public void Log(string str)
{
LogMessageToFile(str);
}
private static void LogMessageToFile(string msg)
{
var sw = File.AppendText(LogFilename);
try
{
var logLine = string.Format(CultureInfo.InvariantCulture, "{0:G}: {1}.", DateTime.Now, msg);
sw.WriteLine(logLine);
}
finally
{
sw.Close();
}
}
}
}