@@ -169,12 +169,13 @@ bool GenerateScriptTemplate(const std::string& outputFilePathStr)
169169
170170int main (int argc, char * argv[])
171171{
172+ ssLOG_SET_CURRENT_THREAD_TARGET_LEVEL (ssLOG_LEVEL_WARNING);
173+
172174 // Parse command line options
173175 int currentArgIndex = 0 ;
174176 std::unordered_map<runcpp2::CmdOptions, std::string> currentOptions;
175-
176177 {
177- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 12 , " Update this" );
178+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 13 , " Update this" );
178179 std::unordered_map<std::string, runcpp2::OptionInfo> longOptionsMap =
179180 {
180181 {
@@ -220,10 +221,14 @@ int main(int argc, char* argv[])
220221 {
221222 " --version" ,
222223 runcpp2::OptionInfo (runcpp2::CmdOptions::VERSION, false )
224+ },
225+ {
226+ " --log-level" ,
227+ runcpp2::OptionInfo (runcpp2::CmdOptions::LOG_LEVEL, true )
223228 }
224229 };
225230
226- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 12 , " Update this" );
231+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 13 , " Update this" );
227232 std::unordered_map<std::string, const runcpp2::OptionInfo&> shortOptionsMap =
228233 {
229234 {" -r" , longOptionsMap.at (" --reset-cache" )},
@@ -253,7 +258,7 @@ int main(int argc, char* argv[])
253258 // Help message
254259 if (currentOptions.count (runcpp2::CmdOptions::HELP))
255260 {
256- static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 12 , " Update this" );
261+ static_assert (static_cast <int >(runcpp2::CmdOptions::COUNT) == 13 , " Update this" );
257262 ssLOG_BASE (" Usage: runcpp2 [options] [input_file]" );
258263 ssLOG_BASE (" Options:" );
259264 ssLOG_BASE (" -r, --[r]eset-cache Deletes all cache and build everything from scratch" );
@@ -266,11 +271,33 @@ int main(int argc, char* argv[])
266271 ssLOG_BASE (" -t, --create-script-[t]emplate <file> Creates/prepend runcpp2 script info template" );
267272 ssLOG_BASE (" -w, --[w]atch Watch script changes and output any compiling errors" );
268273 ssLOG_BASE (" -b, --[b]uild Build the script and copy output files to the working directory" );
269- ssLOG_BASE (" -v, --[v]ersion Show the version of runcpp2" );
274+ ssLOG_BASE (" -v, --[v]ersion Show the version of runcpp2" );
275+ ssLOG_BASE (" --log-level <level> Sets the log level (Normal, Info, Debug) for runcpp2." );
270276
271277 return 0 ;
272278 }
273279
280+ // Set Log level
281+ if (currentOptions.count (runcpp2::CmdOptions::LOG_LEVEL))
282+ {
283+ std::string level = currentOptions.at (runcpp2::CmdOptions::LOG_LEVEL);
284+ runcpp2::Trim (level);
285+ for (int i = 0 ; i < level.size (); ++i)
286+ level[i] = std::tolower (level[i]);
287+
288+ if (level == " info" )
289+ ssLOG_SET_CURRENT_THREAD_TARGET_LEVEL (ssLOG_LEVEL_INFO);
290+ else if (level == " debug" )
291+ ssLOG_SET_CURRENT_THREAD_TARGET_LEVEL (ssLOG_LEVEL_DEBUG);
292+ else if (level == " normal" )
293+ ssLOG_SET_CURRENT_THREAD_TARGET_LEVEL (ssLOG_LEVEL_WARNING);
294+ else
295+ {
296+ ssLOG_ERROR (" Invalid level: " << level);
297+ return -1 ;
298+ }
299+ }
300+
274301 // Show user config path
275302 if (currentOptions.count (runcpp2::CmdOptions::SHOW_USER_CONFIG))
276303 {
@@ -294,7 +321,7 @@ int main(int argc, char* argv[])
294321 ssLOG_ERROR (" Failed reset user config" );
295322 return -1 ;
296323 }
297-
324+ ssLOG_BASE ( " User config reset successful " );
298325 return 0 ;
299326 }
300327
@@ -304,7 +331,10 @@ int main(int argc, char* argv[])
304331 if (!GenerateScriptTemplate (currentOptions.at (runcpp2::CmdOptions::SCRIPT_TEMPLATE)))
305332 return -1 ;
306333 else
334+ {
335+ ssLOG_BASE (" Script template generated" );
307336 return 0 ;
337+ }
308338 }
309339
310340 std::vector<runcpp2::Data::Profile> profiles;
@@ -388,17 +418,19 @@ int main(int argc, char* argv[])
388418 return -1 ;
389419
390420 case runcpp2::PipelineResult::UNEXPECTED_FAILURE:
391- case runcpp2::PipelineResult::SUCCESS:
392421 case runcpp2::PipelineResult::INVALID_BUILD_DIR:
393422 case runcpp2::PipelineResult::INVALID_SCRIPT_INFO:
394423 case runcpp2::PipelineResult::NO_AVAILABLE_PROFILE:
395424 case runcpp2::PipelineResult::DEPENDENCIES_FAILED:
396425 case runcpp2::PipelineResult::COMPILE_LINK_FAILED:
397426 case runcpp2::PipelineResult::INVALID_PROFILE:
398427 case runcpp2::PipelineResult::RUN_SCRIPT_FAILED:
428+ ssLOG_BASE (" Watching..." );
429+ break ;
430+ case runcpp2::PipelineResult::SUCCESS:
431+ ssLOG_BASE (" No error. Watching..." );
399432 break ;
400433 }
401- ssLOG_BASE (" No error. Watching..." );
402434 }
403435
404436 lastScriptWriteTime = ghc::filesystem::last_write_time (script, e);
0 commit comments