fix(logs): Remove hardcoded 2000 line display limit
The log viewer was artificially limiting display to 2000 lines regardless of user's requested amount. Users could request 10k, 40k, or 50k lines but only 2000 were ever shown. Changes: - Remove the hardcoded $maxDisplayLines = 2000 limit in the view - Add MAX_LOG_LINES constant (50,000) in GetLogs component - Enforce maximum limit in backend to prevent extremely large requests - Update input field with max attribute and tooltip Fixes #7803
This commit is contained in:
parent
b7e0f5577d
commit
b484c0cc25
2 changed files with 8 additions and 13 deletions
|
|
@ -21,6 +21,8 @@
|
|||
|
||||
class GetLogs extends Component
|
||||
{
|
||||
public const MAX_LOG_LINES = 50000;
|
||||
|
||||
public string $outputs = '';
|
||||
|
||||
public string $errors = '';
|
||||
|
|
@ -123,6 +125,9 @@ public function getLogs($refresh = false)
|
|||
if ($this->numberOfLines <= 0 || is_null($this->numberOfLines)) {
|
||||
$this->numberOfLines = 1000;
|
||||
}
|
||||
if ($this->numberOfLines > self::MAX_LOG_LINES) {
|
||||
$this->numberOfLines = self::MAX_LOG_LINES;
|
||||
}
|
||||
if ($this->container) {
|
||||
if ($this->showTimeStamps) {
|
||||
if ($this->server->isSwarm()) {
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ class="flex items-center justify-between gap-2 px-4 py-2 border-b dark:border-co
|
|||
<form wire:submit="getLogs(true)" class="relative flex items-center">
|
||||
<span
|
||||
class="absolute left-2 top-1/2 -translate-y-1/2 text-xs text-gray-400 pointer-events-none">Lines:</span>
|
||||
<input type="number" wire:model="numberOfLines" placeholder="100" min="1"
|
||||
title="Number of Lines" {{ $streamLogs ? 'readonly' : '' }}
|
||||
<input type="number" wire:model="numberOfLines" placeholder="100" min="1" max="50000"
|
||||
title="Number of Lines (max 50,000)" {{ $streamLogs ? 'readonly' : '' }}
|
||||
class="input input-sm w-32 pl-11 text-center dark:bg-coolgray-300" />
|
||||
</form>
|
||||
<span x-show="searchQuery.trim()" x-text="matchCount + ' matches'"
|
||||
|
|
@ -374,19 +374,9 @@ class="flex overflow-y-auto overflow-x-hidden flex-col px-4 py-2 w-full min-w-0
|
|||
:class="fullscreen ? 'flex-1' : 'max-h-[40rem]'">
|
||||
@if ($outputs)
|
||||
@php
|
||||
// Limit rendered lines to prevent memory exhaustion
|
||||
$maxDisplayLines = 2000;
|
||||
$allLines = collect(explode("\n", $outputs))->filter(fn($line) => trim($line) !== '');
|
||||
$totalLines = $allLines->count();
|
||||
$hasMoreLines = $totalLines > $maxDisplayLines;
|
||||
$displayLines = $hasMoreLines ? $allLines->slice(-$maxDisplayLines)->values() : $allLines;
|
||||
$displayLines = collect(explode("\n", $outputs))->filter(fn($line) => trim($line) !== '');
|
||||
@endphp
|
||||
<div id="logs" class="font-mono max-w-full cursor-default">
|
||||
@if ($hasMoreLines)
|
||||
<div class="text-center py-2 text-gray-500 dark:text-gray-400 text-sm border-b dark:border-coolgray-300 mb-2">
|
||||
Showing last {{ number_format($maxDisplayLines) }} of {{ number_format($totalLines) }} lines
|
||||
</div>
|
||||
@endif
|
||||
<div x-show="searchQuery.trim() && matchCount === 0"
|
||||
class="text-gray-500 dark:text-gray-400 py-2">
|
||||
No matches found.
|
||||
|
|
|
|||
Loading…
Reference in a new issue