forked from mudzereli/mudsort
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtil.cs
64 lines (61 loc) · 2.04 KB
/
Util.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using mudsort.Properties;
using System;
using System.IO;
namespace mudsort
{
public static class Util
{
public static void Log(String message)
{
try
{
using (StreamWriter writer = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\Asheron's Call\" + Globals.PluginName + " log.txt", true))
{
writer.WriteLine(DateTime.Now.ToString() + ": " + message);
writer.Close();
}
}
catch
{
}
}
public static void LogError(Exception ex)
{
using (StreamWriter writer = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Personal) + @"\Asheron's Call\" + Globals.PluginName + " errors.txt", true))
{
writer.WriteLine("============================================================================");
writer.WriteLine(DateTime.Now.ToString());
writer.WriteLine("Error: " + ex.Message);
writer.WriteLine("Source: " + ex.Source);
writer.WriteLine("Stack: " + ex.StackTrace);
if (ex.InnerException != null)
{
writer.WriteLine("Inner: " + ex.InnerException.Message);
writer.WriteLine("Inner Stack: " + ex.InnerException.StackTrace);
}
writer.WriteLine("============================================================================");
writer.WriteLine("");
writer.Close();
}
}
public static void WriteToChat(string message)
{
try
{
Globals.Host.Actions.AddChatText("[" + Globals.PluginName + "]: " + message, 5);
}
catch (Exception ex) { LogError(ex); }
}
public static void DebugWrite(string message)
{
try
{
if (Settings.Default.Debug)
{
Globals.Host.Actions.AddChatText("[" + Globals.PluginName + "]: " + message, 5);
}
}
catch (Exception ex) { LogError(ex); }
}
}
}