-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConsoleEx.cs
46 lines (40 loc) · 1.5 KB
/
ConsoleEx.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
namespace Xein.Discord.ChatGPT;
public enum ConsoleType
{
Normal,
Debug,
Warn,
Error,
}
public class ConsoleItem
{
public ConsoleItem(string msg, ConsoleType type)
{
File.AppendAllText("console.log", msg + Environment.NewLine);
switch (type)
{
case ConsoleType.Normal:
System.Console.ForegroundColor = ConsoleColor.White;
break;
case ConsoleType.Debug:
System.Console.ForegroundColor = ConsoleColor.Gray;
break;
case ConsoleType.Warn:
System.Console.ForegroundColor = ConsoleColor.Yellow;
break;
case ConsoleType.Error:
System.Console.ForegroundColor = ConsoleColor.Red;
break;
}
System.Console.WriteLine(msg);
System.Console.ForegroundColor = ConsoleColor.White;
}
}
public static class Console
{
private static string GetTime() => DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss:fff tt");
public static void Log(string msg) => new ConsoleItem($"[{GetTime()}] {msg}", ConsoleType.Normal);
public static void Debug(string msg) => new ConsoleItem($"[{GetTime()}] [DEBUG] {msg}", ConsoleType.Debug);
public static void Warn(string msg) => new ConsoleItem($"[{GetTime()}] [WARN] {msg}", ConsoleType.Warn);
public static void Error(string msg) => new ConsoleItem($"[{GetTime()}] [ERROR] {msg}", ConsoleType.Error);
}