-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLogger.cs
37 lines (33 loc) · 1.01 KB
/
Logger.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
using System;
using System.IO;
using Harmony;
namespace WeaponRealizer
{
public static class Logger
{
private static string LogFilePath => $"{Core.ModDirectory}/{Core.ModName}.log";
public static void Error(Exception ex)
{
using (var writer = new StreamWriter(LogFilePath, true))
{
writer.WriteLine($"Message: {ex.Message}");
writer.WriteLine($"StackTrace: {ex.StackTrace}");
WriteLogFooter(writer);
}
}
public static void Debug(String line)
{
if (!Core.ModSettings.debug) return;
using (var writer = new StreamWriter(LogFilePath, true))
{
writer.WriteLine(line);
WriteLogFooter(writer);
}
}
private static void WriteLogFooter(StreamWriter writer)
{
writer.WriteLine($"Date: {DateTime.Now}");
writer.WriteLine(new string(c: '-', count: 80));
}
}
}