Showing error context from the build log when error condition is triggered

This commit is contained in:
Pavel Shevaev 2023-10-23 12:48:15 +03:00
parent a73cc632d4
commit ac3122efed
1 changed files with 12 additions and 7 deletions

View File

@ -1013,8 +1013,9 @@ function watch_running_process($pid, $log_file, $exit_matches = array(), $error_
{
foreach($matches as $match)
{
if(strpos($buffer, $match) !== false)
return true;
$match_idx = strpos($buffer, $match);
if($match_idx !== false)
return $match_idx;
}
return false;
};
@ -1042,18 +1043,22 @@ function watch_running_process($pid, $log_file, $exit_matches = array(), $error_
echo $buffer;
//log success condition
if($matches_any_fn($buffer, $exit_matches))
if($matches_any_fn($buffer, $exit_matches) !== false)
break;
if($matches_any_fn($buffer, $noted_warnings))
if($matches_any_fn($buffer, $noted_warnings) !== false)
$warnings_list[] = $buffer;
if($matches_any_fn($buffer, $error_matches))
$buffer_error_idx = $matches_any_fn($buffer, $error_matches);
if($buffer_error_idx !== false)
{
if($matches_any_fn($buffer, $ignored_errors))
if($matches_any_fn($buffer, $ignored_errors) !== false)
echo "Error in log file IGNORED\n";
else
$throw_fn("Error condition in log file detected");
$throw_fn("Error condition in log file '$log_file' detected:\n****\n" .
trim(substr($buffer, $buffer_error_idx, 300))
. "\n****\n"
);
}
}
else if($process_gone)