forked from nilaoda/BBDown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.cs
61 lines (57 loc) · 2.06 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
namespace BBDown.Core
{
public class Logger
{
public static void Log(object text, bool enter = true)
{
Console.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " - " + text);
if (enter) Console.WriteLine();
}
public static void LogError(object text)
{
Console.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " - ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write(text);
Console.ResetColor();
Console.WriteLine();
}
public static void LogColor(object text, bool time = true)
{
if (time)
Console.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " - ");
Console.ForegroundColor = ConsoleColor.Cyan;
if (time)
Console.Write(text);
else
Console.Write(" " + text);
Console.ResetColor();
Console.WriteLine();
}
public static void LogWarn(object text, bool time = true)
{
if (time)
Console.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " - ");
Console.ForegroundColor = ConsoleColor.DarkYellow;
if (time)
Console.Write(text);
else
Console.Write(" " + text);
Console.ResetColor();
Console.WriteLine();
}
public static void LogDebug(string toFormat, params object[] args)
{
if (Config.DEBUG_LOG)
{
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.Write(DateTime.Now.ToString("[yyyy-MM-dd HH:mm:ss.fff]") + " - ");
if (args.Length > 0)
Console.Write(string.Format(toFormat, args).Trim());
else
Console.Write(toFormat);
Console.ResetColor();
Console.WriteLine();
}
}
}
}