Use yellow as error log color when use RunOpt_Dont_Abort_On_Failure

This commit is contained in:
Mikachu2333 2025-09-13 11:26:27 +08:00 committed by GitHub
parent d1149d8d00
commit d71ea423dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -295,7 +295,7 @@ log_check_result (const char *check_what, const char *check_type, bool exist)
static void
log_cmd_result (bool result, int exit_status)
log_cmd_result (bool result, int exit_status, bool use_yellow_for_error)
{
char *run_msg = NULL;
char *succ_msg = NULL;
@ -320,10 +320,19 @@ log_cmd_result (bool result, int exit_status)
{
char buf[8] = {0};
sprintf (buf, "%d", exit_status);
if (use_yellow_for_error)
{
char *log = xy_2strcat (yellow (fail_msg), bdyellow (buf));
xy_log_brkt (yellow (App_Name), bdyellow (run_msg), log);
}
else
{
char *log = xy_2strcat (red (fail_msg), bdred (buf));
xy_log_brkt (red (App_Name), bdred (run_msg), log);
}
}
}
@ -1312,16 +1321,18 @@ chsrc_run (const char *cmd, int run_option)
}
int status = system (cmd);
bool use_yellow_for_error = (run_option & RunOpt_Dont_Abort_On_Failure) != 0;
if (0==status)
{
if (! (RunOpt_Dont_Notify_On_Success & run_option))
{
log_cmd_result (true, status);
log_cmd_result (true, status, use_yellow_for_error);
}
}
else
{
log_cmd_result (false, status);
log_cmd_result (false, status, use_yellow_for_error);
if (! (run_option & RunOpt_Dont_Abort_On_Failure))
{
char *msg = ENGLISH ? "Fatal error, forced end" : "关键错误,强制结束";