-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathLogger.cs
83 lines (64 loc) · 2.71 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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MapDetection
{
public static class Log
{
public static void LogGeneral(string general, int padCount = 0)
{
var oldColor = SetConsoleColor(ConsoleColor.DarkGreen);
for (int i = 0; i < padCount; i++)
Console.Write(" ");
Console.WriteLine($"[+] {general}");
SetConsoleColor(oldColor);
}
public static void LogInfo(string information, int padCount = 0)
{
var oldColor = SetConsoleColor(ConsoleColor.DarkCyan);
for (int i = 0; i < padCount; i++)
Console.Write(" ");
Console.WriteLine($"[?] {information}");
SetConsoleColor(oldColor);
}
public static void LogVariable<T>(string variableName, T variable, int padCount = 0)
{
var oldColor = SetConsoleColor(ConsoleColor.DarkCyan);
for (int i = 0; i < padCount; i++)
Console.Write(" ");
Console.WriteLine($"[?] {variableName} - {variable}");
SetConsoleColor(oldColor);
}
public static void LogWarning(string error, bool alert = false, int padCount = 0)
{
var oldColor = SetConsoleColor(alert ? ConsoleColor.Red : ConsoleColor.DarkYellow);
for (int i = 0; i < padCount; i++)
Console.Write(" ");
Console.WriteLine($"[!] {error}");
SetConsoleColor(oldColor);
}
public static void LogError(string error, int padCount = 0)
{
var oldColor = SetConsoleColor(ConsoleColor.DarkRed);
for (int i = 0; i < padCount; i++)
Console.Write(" ");
Console.WriteLine($"[!!] {error}");
SetConsoleColor(oldColor);
}
private static ConsoleColor SetConsoleColor(ConsoleColor newColor)
{
var oldColor = Console.ForegroundColor;
Console.ForegroundColor = newColor;
return oldColor;
}
public static void ShowWarning(string message, string title) =>
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
public static void ShowInformation(string message, string title) =>
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
public static void ShowError(string message, string title) =>
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}