-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPrettyPrint.cs
36 lines (30 loc) · 1.14 KB
/
PrettyPrint.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
namespace CefDetector.Net
{
/// <summary>
/// 更加美观的输出
/// </summary>
public static class PrettyPrinter
{
public static void WriteMessage(ConsoleColor color, string title, string contentFmt, params object?[]? args)
{
var originalForeground = Console.ForegroundColor;
var originalBackground = Console.BackgroundColor;
Console.ForegroundColor = color;
Console.Write("[{0}]\t", title);
Console.ForegroundColor = originalForeground;
Console.WriteLine(contentFmt, args);
}
public static void WriteInfo(string title, string contentFmt, params object?[]? args)
{
WriteMessage(ConsoleColor.Green, title, contentFmt, args);
}
public static void WriteWarning(string title, string contentFmt, params object?[]? args)
{
WriteMessage(ConsoleColor.Yellow, title, contentFmt, args);
}
public static void WriteError(string title, string contentFmt, params object?[]? args)
{
WriteMessage(ConsoleColor.Red, title, contentFmt, args);
}
}
}