-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLogger.cs
More file actions
45 lines (42 loc) · 1.11 KB
/
Logger.cs
File metadata and controls
45 lines (42 loc) · 1.11 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
45
using System;
using System.IO;
using MMI_SP.Common;
/// <summary>
/// Static logger class that allows direct logging of anything to a text file
/// </summary>
static class Logger
{
private const string logFileName = "MMI-SP.log";
public static void ResetLogFile()
{
FileStream fs = File.Create(logFileName);
fs.Close();
}
public static void Debug(object message)
{
if (MMI_SP.MMI.IsDebug)
{
Log("Debug - " + Utils.GetCurrentMethod(1) + " " + message);
}
}
public static void Info(object message)
{
Log("Info - " + message);
}
public static void Warning(object message)
{
Log("Warning - " + message);
}
public static void Error(object message)
{
Log("Error - " + Utils.GetCurrentMethod(1) + " " + message);
}
public static void Exception(Exception ex)
{
Log("Exception - " + ex.Message + "\r\n" + ex.StackTrace);
}
private static void Log(object message)
{
File.AppendAllText(logFileName, DateTime.Now + " : " + message + Environment.NewLine);
}
}