-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.cs
More file actions
84 lines (83 loc) · 2.22 KB
/
Logger.cs
File metadata and controls
84 lines (83 loc) · 2.22 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
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
84
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
public class Logger
{
private static ConsoleColor def = ConsoleColor.Gray;
private static ConsoleColor info = ConsoleColor.Cyan;
private static ConsoleColor warn = ConsoleColor.Yellow;
private static ConsoleColor err = ConsoleColor.Red;
private static ConsoleColor ok = ConsoleColor.Green;
private static ConsoleColor txt = ConsoleColor.White;
private static ConsoleColor debug = ConsoleColor.Magenta;
private static void _clr(ConsoleColor clr = ConsoleColor.Red)
{
Console.ForegroundColor = clr;
}
public static void Info(string text)
{
_clr(def);
Console.Write("[");
_clr(info);
Console.Write("INFO");
_clr(def);
Console.Write("] ");
_clr(txt);
Console.WriteLine(text.ToString());
_clr(ConsoleColor.DarkGray);
}
public static void Warn(string text)
{
_clr(def);
Console.Write("[");
_clr(warn);
Console.Write("WARN");
_clr(def);
Console.Write("] ");
_clr(txt);
Console.WriteLine(text.ToString());
_clr(ConsoleColor.DarkGray);
}
public static void Error(string text)
{
_clr(def);
Console.Write("[");
_clr(err);
Console.Write("ERR");
_clr(def);
Console.Write("] ");
_clr(txt);
Console.WriteLine(text.ToString());
_clr(ConsoleColor.DarkGray);
}
public static void Ok(string text)
{
_clr(def);
Console.Write("[");
_clr(ok);
Console.Write("OK");
_clr(def);
Console.Write("] ");
_clr(txt);
Console.WriteLine(text.ToString());
_clr(ConsoleColor.DarkGray);
}
public static bool Debug(string text)
{
if (Debugger.IsAttached)
{
_clr(def);
Console.Write("[");
_clr(debug);
Console.Write("DBG");
_clr(def);
Console.Write("] ");
_clr(txt);
Console.WriteLine(text.ToString());
_clr(ConsoleColor.DarkGray);
return true;
}
else return false;
}
}