deployment log improvements

This commit is contained in:
mahansky
2024-09-03 20:06:03 +02:00
parent eaabf94cd7
commit 63a07e7649
3 changed files with 108 additions and 55 deletions

View File

@@ -234,6 +234,7 @@ function decode_remote_command_output(?ApplicationDeploymentQueue $application_d
return collect([]);
}
// ray($decoded );
$seenCommands = collect();
$formatted = collect($decoded);
if (! $is_debug_enabled) {
$formatted = $formatted->filter(fn ($i) => $i['hidden'] === false ?? false);
@@ -244,7 +245,36 @@ function decode_remote_command_output(?ApplicationDeploymentQueue $application_d
data_set($i, 'timestamp', Carbon::parse(data_get($i, 'timestamp'))->format('Y-M-d H:i:s.u'));
return $i;
});
})
->reduce(function ($deploymentLogLines, $logItem) use ($seenCommands) {
$command = $logItem['command'];
$isStderr = $logItem['type'] === 'stderr';
if (! is_null($command) && ! $seenCommands->contains($command)) {
$deploymentLogLines->push([
'line' => $command,
'timestamp' => $logItem['timestamp'],
'stderr' => $isStderr,
'hidden' => $logItem['hidden'],
'command' => true,
]);
$seenCommands->push($command);
}
$lines = explode(PHP_EOL, $logItem['output']);
foreach ($lines as $line) {
$deploymentLogLines->push([
'line' => $line,
'timestamp' => $logItem['timestamp'],
'stderr' => $isStderr,
'hidden' => $logItem['hidden'],
]);
}
return $deploymentLogLines;
}, collect());
return $formatted;
}