diff --git a/frontend/src/lib/mongo/index.js b/frontend/src/lib/mongo/index.js index 10ecdbe..cd96c7f 100644 --- a/frontend/src/lib/mongo/index.js +++ b/frontend/src/lib/mongo/index.js @@ -2,8 +2,10 @@ import { ObjectId } from 'bson'; import aggregationStages from './aggregation-stages.json'; import atomicUpdateOperators from './atomic-update-operators.json'; import locales from './locales.json'; +import logComponents from './log-components.json'; +import logLevels from './loglevels.json'; -export { aggregationStages, atomicUpdateOperators, locales }; +export { aggregationStages, atomicUpdateOperators, locales, logComponents, logLevels }; // Calculate the min and max values of (un)signed integers with n bits export const intMin = bits => Math.pow(2, bits - 1) * -1; diff --git a/frontend/src/lib/mongo/log-components.json b/frontend/src/lib/mongo/log-components.json new file mode 100644 index 0000000..1e349c6 --- /dev/null +++ b/frontend/src/lib/mongo/log-components.json @@ -0,0 +1,36 @@ +[ + "ACCESS", + "COMMAND", + "CONTROL", + "ELECTION", + "FTDC", + "GEO", + "INDEX", + "INITSYNC", + "JOURNAL", + "NETWORK", + "QUERY", + "RECOVERY", + "REPL", + "REPL_HB", + "ROLLBACK", + "SHARDING", + "STORAGE", + "TXN", + "WRITE", + "WT", + "WTBACKUP", + "WTCHKPT", + "WTCMPCT", + "WTEVICT", + "WTHS", + "WTRECOV", + "WTRTS", + "WTSLVG", + "WTTIER", + "WTTS", + "WTTXN", + "WTVRFY", + "WTWRTLOG", + "-" +] diff --git a/frontend/src/lib/mongo/loglevels.json b/frontend/src/lib/mongo/loglevels.json new file mode 100644 index 0000000..28d9ec4 --- /dev/null +++ b/frontend/src/lib/mongo/loglevels.json @@ -0,0 +1,7 @@ +{ + "F": "Fatal", + "E": "Error", + "W": "Warning", + "I": "Info", + "D": "Debug" +} diff --git a/frontend/src/organisms/connection/host/logs.svelte b/frontend/src/organisms/connection/host/logs.svelte index 5271e1d..6b105e1 100644 --- a/frontend/src/organisms/connection/host/logs.svelte +++ b/frontend/src/organisms/connection/host/logs.svelte @@ -3,6 +3,7 @@ import Icon from '$components/icon.svelte'; import ObjectViewer from '$components/objectviewer.svelte'; import input from '$lib/actions/input'; + import { logComponents, logLevels } from '$lib/mongo'; import { BrowserOpenURL } from '$wails/runtime/runtime'; import { onDestroy } from 'svelte'; @@ -10,6 +11,8 @@ const autoReloadIntervals = [ 1, 2, 5, 10, 30, 60 ]; let filter = 'global'; + let severityFilter = ''; + let componentFilter = ''; let logs; let total = 0; let error = ''; @@ -17,7 +20,7 @@ let autoReloadInterval = 0; let objectViewerData; let interval; - $: filter && refresh(); + $: (filter || severityFilter || componentFilter) && refresh(); $: busy = !logs && !error && 'Requesting logsā€¦'; $: if (autoReloadInterval) { @@ -30,12 +33,19 @@ async function refresh() { let _logs = []; ({ logs: _logs, total, error } = await host.getLogs(filter)); - logs = []; + for (let index = 0; index < _logs.length; index++) { const log = JSON.parse(_logs[index]); - log._index = index; - logs = [ ...logs, log ]; + + const matchesLevel = severityFilter ? log.s?.startsWith(severityFilter) : true; + const matchesComponent = componentFilter ? (componentFilter === log.c?.toUpperCase()) : true; + + if (matchesLevel && matchesComponent) { + log._index = index; + log.s = logLevels[log.s] || log.s; + logs = [ ...logs, log ]; + } } } @@ -62,6 +72,46 @@
+
+ + + +
+ +
+ + + +
+
-
-
- + - -
- - - - -
+ {#if total}
@@ -133,10 +164,16 @@ .stats { display: grid; gap: 0.5rem; - grid-template: 1fr auto / 1fr; + grid-template: auto auto 1fr auto / 1fr; } - .stats .grid { + .formrow { + display: grid; + gap: 0.5rem; + grid-template: 1fr / 1fr 1fr; + } + + .grid { overflow: auto; min-height: 0; min-width: 0; @@ -146,7 +183,7 @@ .controls { display: flex; align-items: center; - gap: 0.1rem; + gap: 0.2rem; } .total { margin-left: auto;