forked from bippity/Jist
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ScriptLog.cs
executable file
·89 lines (75 loc) · 2.49 KB
/
ScriptLog.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
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Wolfje.Plugins.Jist {
public class ScriptLog {
static readonly object __lockSyncLock = new object();
public static void PrintSuccess(string MessageFormat, params object[] args)
{
lock (__lockSyncLock) {
int defaultWindowWidth = default(int);
string s = string.Format(MessageFormat, args);
ConsoleColor origColour = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Green;
try {
defaultWindowWidth = Console.WindowWidth;
Console.SetCursorPosition(defaultWindowWidth - s.Length - 3, Console.CursorTop);
} catch {
Console.Write('\t');
defaultWindowWidth = 80;
}
Console.WriteLine(s);
Console.ForegroundColor = origColour;
}
}
public static void PrintError(string MessageFormat, params object[] args)
{
lock (__lockSyncLock) {
int defaultWindowWidth = default(int);
string s = string.Format(MessageFormat, args);
ConsoleColor origColour = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
try {
defaultWindowWidth = Console.WindowWidth;
Console.SetCursorPosition(defaultWindowWidth - s.Length - 3, Console.CursorTop);
} catch {
Console.Write('\t');
defaultWindowWidth = 80;
}
Console.WriteLine(s);
Console.ForegroundColor = origColour;
}
}
public static void InfoFormat(string ScriptName, string MessageFormat, params object[] args)
{
lock (__lockSyncLock) {
ConsoleColor origColour = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("[jist {0}] ", ScriptName);
Console.ForegroundColor = origColour;
Console.Write(MessageFormat, args);
}
}
public static void InfoLineFormat(string ScriptName, string MessageFormat, params object[] args)
{
lock (__lockSyncLock) {
ConsoleColor origColour = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("[jist {0}] ", ScriptName);
Console.ForegroundColor = origColour;
Console.WriteLine(MessageFormat, args);
}
}
public static void ErrorFormat(string ScriptName, string MessageFormat, params object[] args)
{
lock (__lockSyncLock) {
ConsoleColor origColour = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("[jist {0} error] ", ScriptName);
Console.WriteLine(MessageFormat, args);
Console.ForegroundColor = origColour;
}
}
}
}