@@ -38,6 +38,7 @@ public static void ClearConsole()
38
38
WriteColor ( $ "[// Check the Collection Id:] { Program . Settings . SteamCollection } ", ConsoleColor . DarkGreen ) ;
39
39
var ids = Program . Settings . SteamCollection ? Program . Settings . SteamCollectionId . ToString ( ) : String . Join ( ", " , Program . Settings . SteamModIds . ToArray ( ) ) ;
40
40
WriteColor ( $ "[// Collection Id or Mod Ids:] { ids } ", ConsoleColor . DarkGreen ) ;
41
+ WriteColor ( $ "[// Logfile:] { Program . Settings . LogFile } ", ConsoleColor . DarkGreen ) ;
41
42
WriteColor ( @"[//--Options------------------------------------------------------]" , ConsoleColor . DarkGreen ) ;
42
43
WriteColor ( $ "[// 1:] Execute Refresh", ConsoleColor . DarkGreen ) ;
43
44
WriteColor ( $ "[// 2:] Reload settings.json", ConsoleColor . DarkGreen ) ;
@@ -47,17 +48,17 @@ public static void ClearConsole()
47
48
48
49
if ( string . IsNullOrEmpty ( Program . Settings . SteamApiKey ) )
49
50
{
50
- WriteColor ( @"[//--No Steam API Key---------------------------------------------]" , ConsoleColor . DarkRed ) ;
51
- WriteColor ( $ "[//:] Please insert a Steam API Key into the Settings.json", ConsoleColor . DarkRed ) ;
52
- WriteColor ( @"[//---------------------------------------------------------------]" , ConsoleColor . DarkRed ) ;
51
+ WriteColor ( @"[//--No Steam API Key---------------------------------------------]" , ConsoleColor . DarkRed , true ) ;
52
+ WriteColor ( $ "[//:] Please insert a Steam API Key into the Settings.json", ConsoleColor . DarkRed , true ) ;
53
+ WriteColor ( @"[//---------------------------------------------------------------]" , ConsoleColor . DarkRed , true ) ;
53
54
Environment . Exit ( 1 ) ;
54
55
}
55
56
56
57
if ( string . IsNullOrEmpty ( Program . Settings . SteamApiKey ) )
57
58
{
58
- WriteColor ( @"[//--No Discord Web Hook------------------------------------------]" , ConsoleColor . DarkRed ) ;
59
- WriteColor ( $ "[//:] Please insert a Discord Web Hook into the Settings.json", ConsoleColor . DarkRed ) ;
60
- WriteColor ( @"[//---------------------------------------------------------------]" , ConsoleColor . DarkRed ) ;
59
+ WriteColor ( @"[//--No Discord Web Hook------------------------------------------]" , ConsoleColor . DarkRed , true ) ;
60
+ WriteColor ( $ "[//:] Please insert a Discord Web Hook into the Settings.json", ConsoleColor . DarkRed , true ) ;
61
+ WriteColor ( @"[//---------------------------------------------------------------]" , ConsoleColor . DarkRed , true ) ;
61
62
Environment . Exit ( 2 ) ;
62
63
}
63
64
}
@@ -69,30 +70,36 @@ public static void ClearConsole()
69
70
/// <param name="exitCode"></param>
70
71
public static void CriticalError ( string text , int exitCode )
71
72
{
72
- WriteColor ( @"[//--Critical Error-----------------------------------------------]" , ConsoleColor . DarkRed ) ;
73
- WriteColor ( $ "[//:] { text } ", ConsoleColor . DarkRed ) ;
74
- WriteColor ( @"[//---------------------------------------------------------------]" , ConsoleColor . DarkRed ) ;
73
+ WriteColor ( @"[//--Critical Error-----------------------------------------------]" , ConsoleColor . DarkRed , true ) ;
74
+ WriteColor ( $ "[//:] { text } ", ConsoleColor . DarkRed , true ) ;
75
+ WriteColor ( @"[//---------------------------------------------------------------]" , ConsoleColor . DarkRed , true ) ;
75
76
Environment . Exit ( exitCode ) ;
76
77
}
77
78
78
79
/// <summary>
79
80
/// Set a error message into the console
80
81
/// </summary>
81
82
/// <param name="text">Information text</param>
82
- public static void Error ( string text )
83
+ #nullable enable
84
+ public static void Error ( string text , string ? debug = null )
83
85
{
84
- WriteColor ( @"[// We got an Error...]" , ConsoleColor . DarkRed ) ;
85
- WriteColor ( $ "[// ]{ text } ", ConsoleColor . DarkRed ) ;
86
- WriteColor ( @"[// Continue application...]" , ConsoleColor . DarkRed ) ;
86
+ WriteColor ( @"[// We got an Error...]" , ConsoleColor . DarkRed , true ) ;
87
+ WriteColor ( $ "[// ]{ text } ", ConsoleColor . DarkRed , true ) ;
88
+ if ( debug != null || string . IsNullOrEmpty ( debug ) )
89
+ {
90
+ WriteColor ( $ "[// ]{ debug } ", ConsoleColor . DarkYellow , true ) ;
91
+ }
92
+ WriteColor ( @"[// Continue application...]" , ConsoleColor . DarkRed , true ) ;
87
93
}
94
+ #nullable disable
88
95
89
96
/// <summary>
90
97
/// Write some coloring console messages for the user
91
98
/// https://stackoverflow.com/questions/2743260/is-it-possible-to-write-to-the-console-in-colour-in-net
92
99
/// </summary>
93
100
/// <param name="message">Message to write</param>
94
101
/// <param name="color">ConsoleColor value of the color</param>
95
- public static void WriteColor ( string message , ConsoleColor color )
102
+ public static void WriteColor ( string message , ConsoleColor color , bool isError = false )
96
103
{
97
104
var pieces = Regex . Split ( message , @"(\[[^\]]*\])" ) ;
98
105
@@ -111,6 +118,18 @@ public static void WriteColor(string message, ConsoleColor color)
111
118
}
112
119
113
120
Console . WriteLine ( ) ;
121
+
122
+ if ( Program . LogFile != null )
123
+ {
124
+ if ( isError )
125
+ {
126
+ Program . LogFile . Error ( message ) ;
127
+ }
128
+ else
129
+ {
130
+ Program . LogFile . Information ( message ) ;
131
+ }
132
+ }
114
133
}
115
134
}
116
135
}
0 commit comments