Merge pull request #5038 from Vann-Dev/main

feat(api): add applications logs api
This commit is contained in:
Andras Bacsai
2025-02-04 13:33:30 +01:00
committed by GitHub
3 changed files with 120 additions and 0 deletions

View File

@@ -852,6 +852,23 @@ function validateComposeFile(string $compose, int $server_id): string|Throwable
}
}
function getContainerLogs(Server $server, string $container_id, int $lines = 100): string
{
if ($server->isSwarm()) {
$output = instant_remote_process([
"docker service logs -n {$lines} {$container_id}",
], $server);
} else {
$output = instant_remote_process([
"docker logs -n {$lines} {$container_id}",
], $server);
}
$output .= removeAnsiColors($output);
return $output;
}
function escapeEnvVariables($value)
{
$search = ['\\', "\r", "\t", "\x0", '"', "'"];