From a73360e5036ed38e90b54bc4af1a5f803416fa86 Mon Sep 17 00:00:00 2001 From: ShadowArcanist <162910371+ShadowArcanist@users.noreply.github.com> Date: Fri, 6 Mar 2026 10:53:30 +0530 Subject: [PATCH] feat(ui): add log filter based on log level --- .../project/shared/get-logs.blade.php | 75 ++++++++++++++++--- 1 file changed, 65 insertions(+), 10 deletions(-) diff --git a/resources/views/livewire/project/shared/get-logs.blade.php b/resources/views/livewire/project/shared/get-logs.blade.php index 1df4bae7e..ee5b65cf5 100644 --- a/resources/views/livewire/project/shared/get-logs.blade.php +++ b/resources/views/livewire/project/shared/get-logs.blade.php @@ -8,6 +8,7 @@ rafId: null, scrollDebounce: null, colorLogs: localStorage.getItem('coolify-color-logs') === 'true', + logFilters: JSON.parse(localStorage.getItem('coolify-log-filters')) || {error: true, warning: true, debug: true, info: true}, searchQuery: '', matchCount: 0, containerName: '{{ $container ?? "logs" }}', @@ -70,6 +71,17 @@ } }, 150); }, + getLogLevel(content) { + if (/\b(error|err|failed|failure|exception|fatal|panic|critical)\b/.test(content)) return 'error'; + if (/\b(warn|warning|wrn|caution)\b/.test(content)) return 'warning'; + if (/\b(debug|dbg|trace|verbose)\b/.test(content)) return 'debug'; + return 'info'; + }, + toggleLogFilter(level) { + this.logFilters[level] = !this.logFilters[level]; + localStorage.setItem('coolify-log-filters', JSON.stringify(this.logFilters)); + this.applySearch(); + }, toggleColorLogs() { this.colorLogs = !this.colorLogs; localStorage.setItem('coolify-color-logs', this.colorLogs); @@ -81,17 +93,11 @@ const lines = logs.querySelectorAll('[data-log-line]'); lines.forEach(line => { const content = (line.dataset.logContent || '').toLowerCase(); + const level = this.getLogLevel(content); + line.dataset.logLevel = level; line.classList.remove('log-error', 'log-warning', 'log-debug', 'log-info'); if (!this.colorLogs) return; - if (/\b(error|err|failed|failure|exception|fatal|panic|critical)\b/.test(content)) { - line.classList.add('log-error'); - } else if (/\b(warn|warning|wrn|caution)\b/.test(content)) { - line.classList.add('log-warning'); - } else if (/\b(debug|dbg|trace|verbose)\b/.test(content)) { - line.classList.add('log-debug'); - } else { - line.classList.add('log-info'); - } + line.classList.add('log-' + level); }); }, hasActiveLogSelection() { @@ -118,7 +124,10 @@ lines.forEach(line => { const content = (line.dataset.logContent || '').toLowerCase(); const textSpan = line.querySelector('[data-line-text]'); - const matches = !query || content.includes(query); + const level = line.dataset.logLevel || this.getLogLevel(content); + const passesFilter = this.logFilters[level] !== false; + const matchesSearch = !query || content.includes(query); + const matches = passesFilter && matchesSearch; line.classList.toggle('hidden', !matches); if (matches && query) count++; @@ -389,6 +398,52 @@ class="p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text- d="M9.53 16.122a3 3 0 0 0-5.78 1.128 2.25 2.25 0 0 1-2.4 2.245 4.5 4.5 0 0 0 8.4-2.245c0-.399-.078-.78-.22-1.128Zm0 0a15.998 15.998 0 0 0 3.388-1.62m-5.043-.025a15.994 15.994 0 0 1 1.622-3.395m3.42 3.42a15.995 15.995 0 0 0 4.764-4.648l3.876-5.814a1.151 1.151 0 0 0-1.597-1.597L14.146 6.32a15.996 15.996 0 0 0-4.649 4.763m3.42 3.42a6.776 6.776 0 0 0-3.42-3.42" /> +
+ +
+
+ + + + +
+
+