@@ -38,6 +38,7 @@ public static void ClearConsole()
3838 WriteColor ( $ "[// Check the Collection Id:] { Program . Settings . SteamCollection } ", ConsoleColor . DarkGreen ) ;
3939 var ids = Program . Settings . SteamCollection ? Program . Settings . SteamCollectionId . ToString ( ) : String . Join ( ", " , Program . Settings . SteamModIds . ToArray ( ) ) ;
4040 WriteColor ( $ "[// Collection Id or Mod Ids:] { ids } ", ConsoleColor . DarkGreen ) ;
41+ WriteColor ( $ "[// Logfile:] { Program . Settings . LogFile } ", ConsoleColor . DarkGreen ) ;
4142 WriteColor ( @"[//--Options------------------------------------------------------]" , ConsoleColor . DarkGreen ) ;
4243 WriteColor ( $ "[// 1:] Execute Refresh", ConsoleColor . DarkGreen ) ;
4344 WriteColor ( $ "[// 2:] Reload settings.json", ConsoleColor . DarkGreen ) ;
@@ -47,17 +48,17 @@ public static void ClearConsole()
4748
4849 if ( string . IsNullOrEmpty ( Program . Settings . SteamApiKey ) )
4950 {
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 ) ;
5354 Environment . Exit ( 1 ) ;
5455 }
5556
5657 if ( string . IsNullOrEmpty ( Program . Settings . SteamApiKey ) )
5758 {
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 ) ;
6162 Environment . Exit ( 2 ) ;
6263 }
6364 }
@@ -69,30 +70,36 @@ public static void ClearConsole()
6970 /// <param name="exitCode"></param>
7071 public static void CriticalError ( string text , int exitCode )
7172 {
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 ) ;
7576 Environment . Exit ( exitCode ) ;
7677 }
7778
7879 /// <summary>
7980 /// Set a error message into the console
8081 /// </summary>
8182 /// <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 )
8385 {
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 ) ;
8793 }
94+ #nullable disable
8895
8996 /// <summary>
9097 /// Write some coloring console messages for the user
9198 /// https://stackoverflow.com/questions/2743260/is-it-possible-to-write-to-the-console-in-colour-in-net
9299 /// </summary>
93100 /// <param name="message">Message to write</param>
94101 /// <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 )
96103 {
97104 var pieces = Regex . Split ( message , @"(\[[^\]]*\])" ) ;
98105
@@ -111,6 +118,18 @@ public static void WriteColor(string message, ConsoleColor color)
111118 }
112119
113120 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+ }
114133 }
115134 }
116135}
0 commit comments