LogViewer
Log lines to read and search: time, level, where they came from and the message. Filter by level and by words; long logs paginate. On phones the time and level sit above the message.
import { LogViewer, LogViewerSkeleton } from '@sypnia/ui/react'
640 lines
Filter by level, search «500» and move through the pages.
- errorapiGET /orders 500: the database did not answer in 5 s
- infoapiGET /customers 200 41 ms
- infoapiGET /products 200 42 ms
- infoapiGET /auth/login 200 43 ms
- infoapiGET /orders 200 44 ms
- debugapiGET /customers 200 45 ms
- infoapiGET /products 200 46 ms
- infoapiGET /auth/login 200 47 ms
- infoapiGET /orders 200 48 ms
- infoapiGET /customers 200 49 ms
- debugapiGET /products 200 50 ms
- warnapiGET /auth/login took 1.8 s
- infoapiGET /orders 200 52 ms
- infoapiGET /customers 200 53 ms
- infoapiGET /products 200 54 ms
- debugapiGET /auth/login 200 55 ms
- infoapiGET /orders 200 56 ms
- infoapiGET /customers 200 57 ms
- infoapiGET /products 200 58 ms
- infoapiGET /auth/login 200 59 ms
- debugapiGET /orders 200 60 ms
- infoapiGET /customers 200 61 ms
- warnapiGET /products took 1.8 s
- infoapiGET /auth/login 200 63 ms
- infoapiGET /orders 200 64 ms
- debugapiGET /customers 200 65 ms
- infoapiGET /products 200 66 ms
- infoapiGET /auth/login 200 67 ms
- infoapiGET /orders 200 68 ms
- infoapiGET /customers 200 69 ms
- debugapiGET /products 200 70 ms
- infoapiGET /auth/login 200 71 ms
- infoapiGET /orders 200 72 ms
- warnapiGET /customers took 1.8 s
- infoapiGET /products 200 74 ms
- debugapiGET /auth/login 200 75 ms
- infoapiGET /orders 200 76 ms
- errorapiGET /customers 500: the database did not answer in 5 s
- infoapiGET /products 200 78 ms
- infoapiGET /auth/login 200 79 ms
- debugapiGET /orders 200 80 ms
- infoapiGET /customers 200 81 ms
- infoapiGET /products 200 82 ms
- infoapiGET /auth/login 200 83 ms
- warnapiGET /orders took 1.8 s
- debugapiGET /customers 200 85 ms
- infoapiGET /products 200 86 ms
- infoapiGET /auth/login 200 87 ms
- infoapiGET /orders 200 88 ms
- infoapiGET /customers 200 89 ms
- debugapiGET /products 200 90 ms
- infoapiGET /auth/login 200 91 ms
- infoapiGET /orders 200 92 ms
- infoapiGET /customers 200 93 ms
- infoapiGET /products 200 94 ms
- warnapiGET /auth/login took 1.8 s
- infoapiGET /orders 200 96 ms
- infoapiGET /customers 200 97 ms
- infoapiGET /products 200 98 ms
- infoapiGET /auth/login 200 99 ms
- debugapiGET /orders 200 40 ms
- infoapiGET /customers 200 41 ms
- infoapiGET /products 200 42 ms
- infoapiGET /auth/login 200 43 ms
- infoapiGET /orders 200 44 ms
- debugapiGET /customers 200 45 ms
- warnapiGET /products took 1.8 s
- infoapiGET /auth/login 200 47 ms
- infoapiGET /orders 200 48 ms
- infoapiGET /customers 200 49 ms
- debugapiGET /products 200 50 ms
- infoapiGET /auth/login 200 51 ms
- infoapiGET /orders 200 52 ms
- infoapiGET /customers 200 53 ms
- errorapiGET /products 500: the database did not answer in 5 s
- debugapiGET /auth/login 200 55 ms
- infoapiGET /orders 200 56 ms
- warnapiGET /customers took 1.8 s
- infoapiGET /products 200 58 ms
- infoapiGET /auth/login 200 59 ms
- debugapiGET /orders 200 60 ms
- infoapiGET /customers 200 61 ms
- infoapiGET /products 200 62 ms
- infoapiGET /auth/login 200 63 ms
- infoapiGET /orders 200 64 ms
- debugapiGET /customers 200 65 ms
- infoapiGET /products 200 66 ms
- infoapiGET /auth/login 200 67 ms
- warnapiGET /orders took 1.8 s
- infoapiGET /customers 200 69 ms
- debugapiGET /products 200 70 ms
- infoapiGET /auth/login 200 71 ms
- infoapiGET /orders 200 72 ms
- infoapiGET /customers 200 73 ms
- infoapiGET /products 200 74 ms
- debugapiGET /auth/login 200 75 ms
- infoapiGET /orders 200 76 ms
- infoapiGET /customers 200 77 ms
- infoapiGET /products 200 78 ms
- warnapiGET /auth/login took 1.8 s
1–100 of 640
Code
import { useMemo } from 'react';
import { LogViewer, type LogLine } from '@sypnia/ui/react';
const paths = ['/orders', '/customers', '/products', '/auth/login'];
// 640 lines of an API: filter by level, search for words, and move through the pages.
export default function Tail() {
const lines = useMemo<LogLine[]>(() => Array.from({ length: 640 }, (_, i) => {
const level = i % 37 === 0 ? 'error' : i % 11 === 0 ? 'warn' : i % 5 === 0 ? 'debug' : 'info';
const path = paths[i % paths.length];
return {
id: i, time: Date.UTC(2026, 10, 17, 12, 0, 0) - i * 7000, level, source: 'api',
message: level === 'error' ? `GET ${path} 500: the database did not answer in 5 s` : level === 'warn' ? `GET ${path} took 1.8 s` : `GET ${path} 200 ${40 + (i % 60)} ms`,
};
}), []);
return <LogViewer label="API logs" lines={lines} />;
} Loading and empty
Choose a state.
Code
import { useState } from 'react';
import { LogViewer, SegmentedControl } from '@sypnia/ui/react';
// Loading draws skeleton lines; with no lines it says so.
export default function States() {
const [state, setState] = useState('loading');
return (
<div className="sy-stack">
<SegmentedControl label="State" value={state} onChange={setState} options={[{ value: 'loading', label: 'Loading' }, { value: 'empty', label: 'Empty' }]} />
<LogViewer label="Worker logs" lines={state === 'empty' ? [] : undefined} loading={state === 'loading'} />
</div>
);
} Skeleton
The real piece and its skeleton: the same box, so nothing moves when the data arrives.
- infocronBackup finished in 4 min
Code
import { LogViewer, LogViewerSkeleton } from '@sypnia/ui/react';
// Before anything is known, beside a real one.
export default function Skeleton() {
return (
<div className="sy-stack">
<LogViewer label="Cron logs" lines={[{ time: Date.UTC(2026, 10, 17, 3, 0), level: 'info', source: 'cron', message: 'Backup finished in 4 min' }]} />
<LogViewerSkeleton lines={3} />
</div>
);
} When to use it
Use it when
- The logs of a service, a job or a deploy.
Do not use it when
- It is a short session of commands: Terminal.
- It is a list of events for people, not machines: Timeline.
For everyone
- Levels are buttons that say whether they are on; errors carry an icon and the word, not only red.
- While loading it draws skeleton lines and is busy; with no lines it says so.
Props
| LogViewer | Type | Default |
|---|---|---|
labelrequired | string | |
linesrequired | LogLine[] | undefined | |
empty | ReactNode | |
loading | boolean | |
pageSize | number | 100 |
| LogViewerSkeleton | Type | Default |
|---|---|---|
lines | number | 8 |
pagination | boolean |