diff --git a/app/Livewire/Project/Shared/GetLogs.php b/app/Livewire/Project/Shared/GetLogs.php index 0f8c4ad15..5f8046efd 100644 --- a/app/Livewire/Project/Shared/GetLogs.php +++ b/app/Livewire/Project/Shared/GetLogs.php @@ -188,6 +188,50 @@ public function copyLogs(): string return sanitizeLogsForExport($this->outputs); } + public function downloadAllLogs(): string + { + if (! $this->server->isFunctional() || ! $this->container) { + return ''; + } + + if ($this->showTimeStamps) { + if ($this->server->isSwarm()) { + $command = "docker service logs -t {$this->container}"; + } else { + $command = "docker logs -t {$this->container}"; + } + } else { + if ($this->server->isSwarm()) { + $command = "docker service logs {$this->container}"; + } else { + $command = "docker logs {$this->container}"; + } + } + + if ($this->server->isNonRoot()) { + $command = parseCommandsByLineForSudo(collect($command), $this->server); + $command = $command[0]; + } + + $sshCommand = SshMultiplexingHelper::generateSshCommand($this->server, $command); + + $allLogs = ''; + Process::run($sshCommand, function (string $type, string $output) use (&$allLogs) { + $allLogs .= removeAnsiColors($output); + }); + + if ($this->showTimeStamps) { + $allLogs = str($allLogs)->split('/\n/')->sort(function ($a, $b) { + $a = explode(' ', $a); + $b = explode(' ', $b); + + return $a[0] <=> $b[0]; + })->join("\n"); + } + + return sanitizeLogsForExport($allLogs); + } + public function render() { return view('livewire.project.shared.get-logs'); diff --git a/resources/views/livewire/project/shared/get-logs.blade.php b/resources/views/livewire/project/shared/get-logs.blade.php index 8deee486d..2d964f0bb 100644 --- a/resources/views/livewire/project/shared/get-logs.blade.php +++ b/resources/views/livewire/project/shared/get-logs.blade.php @@ -316,14 +316,49 @@ class="p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text- d="M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75" /> - +
+ +
+
+ + +
+
+