Widgets
LogStream
Virtualised log output: ANSI colours, filters, follow-tail.
A stream of logs: ANSI colours, filtering by level and substring, match highlighting and follow-tail. The framework is called pathlogs — and had no log output in it.
Installation
npx @toimetdev/pathlogs-ui add log-streamExample
1inf12:04:01 info сборка запущена
2inf12:04:02 info разрешение зависимостей…
3deb12:04:05 debug кэш попал в 128 из 130 модулей
4war12:04:06 warn пакет left-pad помечен устаревшим
5inf12:04:08 info компиляция TypeScript
6err12:04:12 error TS2304: не найдено имя «ReactNode»
7err12:04:12 error в src/panel/View.tsx:182
8war12:04:13 warn сборка продолжена с ошибками типов
9inf12:04:01 info сборка запущена
10inf12:04:02 info разрешение зависимостей…
11deb12:04:05 debug кэш попал в 128 из 130 модулей
12war12:04:06 warn пакет left-pad помечен устаревшим
13inf12:04:08 info компиляция TypeScript
<LogStream lines={lines} follow height={320} />Click the levels in the toolbar — the filter is built from whichever are selected. Search highlights matches right inside the lines.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
lines* | LogLine[] | — | The lines: seq, text, level?, at?, source?. |
follow | boolean | true | Stick to the end as lines arrive. |
toolbar | boolean | true | The search and level toolbar. |
lineNumbers | boolean | true | Line numbers on the left. |
wrap | boolean | false | Wrap long lines instead of scrolling horizontally. |
onSelectLine | (line) => void | — | A click on a line. |
height | number | string | 420 | The height of the scroll area. |
lines*LogLine[]The lines: seq, text, level?, at?, source?.
followbooleandefaults to: true
Stick to the end as lines arrive.
toolbarbooleandefaults to: true
The search and level toolbar.
lineNumbersbooleandefaults to: true
Line numbers on the left.
wrapbooleandefaults to: false
Wrap long lines instead of scrolling horizontally.
onSelectLine(line) => voidA click on a line.
heightnumber | stringdefaults to: 420
The height of the scroll area.
Virtualisation
The parsing, separately
import { parseAnsi, stripAnsi } from "@/components/ui/log-stream/ansi";
import {
appendLines, // append to the buffer, evicting anything over the limit
filterLines, // filter by level, source and substring
matchRanges, // match ranges for highlighting
} from "@/components/ui/log-stream/logBuffer";