Log viewer

Shows a job's output lines as they stream.

Toolbar

  • run_8f2a918 lines
    1 failed line

    offdefault

  • run_8f2a918 lines
    1 failed line

    on

States

  • run_8f2a914 lines

    rest

  • run_8f2a914 linesStreaming

    streaming

  • run_8f2a914 lines
    1 failed line

    failed

  • run_8f2a910 linesStreaming

    Waiting for the first line.

    waiting

  • run_8f2a910 lines

    No output.

    empty

Usage

When to use it
Use
A job's, a pipeline's or a worker's output, line by line, often while it still runs.
Use
Finding the failure in a long log: Next failure, and the toolbar's search and levels.
Not for
A file or a command to read and copy. Use Code block.
Not for
The step's source with the line that failed. Use Code window.
Not for
Structured data to fold. Use JSON view.

Rules

6 rules
Must
Give every line a level ('debug', 'info', 'warn' or 'fail') and a stable id. Because the level sets the line's word, the failure band, the counts and Next failure, and the id keeps the windowed rows and their measured heights in place as lines arrive.
Must
Set streaming while lines arrive and append to lines; never replace the array with only the new ones. Because follow keeps the bottom in view and counts what arrived while the reader scrolled up, which needs every line.
Should
Turn toolbar on for a log longer than a screen or two; leave it off for a short one. Because a search and four level filters over eight lines is more chrome than log.
Never
Colour a message by its level; the level word and the failure band carry it. Because colour in Sodium is status and always comes with a word, and a block of red text is hard to read.
Must
Give name the run, job or worker the log belongs to, as written; label stays the kind of log and is only shown when there is no name. Because the head row is the region header, the name first as written and the counts at the end, and label and name together name the log region for a screen reader, so a page with two logs can be told apart.
Never
Wrap a LogViewer in a panel, a frame or a CodeBlock. Because the log is a frame already, and a box in a box is two edges where Sodium draws one.

State order

4 states, highest first
1
empty
2
streaming
3
failed
4
rest

Accessibility

5 checks
The lines are a role="log" region named by label and name, one tab stop, scrolled by the arrow keys; it does not announce every line.
A status line says how many lines failed; Next failure is named "Next failure, 2 in this log".
Level words are text-3, --warn-text or --fail-text, 4.9:1 or more on the well and the failure band.
Copy lines and a hand selection both copy "time LEVEL source message", one line each.
The level filters are toggles with their counts read as descriptions; the search is a search field; wrap is a pressed button.

Keyboard

3 keys
Tab
Moves through the head row's buttons, the toolbar and the log body.
Arrow keys, Page Up / Down
Scroll the focused log.
Escape
In the search, clears it.

Edge cases

6 edge cases
100,000 lines
Only the lines in view render; Copy lines joins them only on press.
Reader scrolled up while streaming
Following stops and a button counts the new lines; it jumps back.
No lines yet
Says "Waiting for the first line." while streaming and "No output." after, in a body that tall; it takes height when the first line arrives.
Filter matches nothing
Says which query or levels emptied it.
Long line
Wraps anywhere; with wrap off, the log scrolls sideways.
Right to left page
The log stays left to right, like code.

API

10 props
lines
LogLine[]
label
string default 'Logs'
name
string
streaming
boolean default false
follow
boolean default true
toolbar
boolean default false
header
boolean default true
timestamps
boolean default true
wrap
boolean default true
height
number default 320

Tokens

16 tokens
--code-surface
var(--well)
--panel
#fafaf7
--line
#e2dfd5
--selected
#fff4bf
--fail-tint
#fdecea
--fail-text
#b3261e
--warn-text
#a14b00
--text-1
#161512
--text-2
#55524a
--text-3
#6b675e
--type-code
400 13px/20px var(--font-mono)
--type-code-sm
400 12px/16px var(--font-mono)
--type-label
400 13px/16px var(--font-mono)
--row
40px
--control-sm
26px
--space-4
16px

Install

For your coding agent

GitHub

Please star me pookie

198

A new design system every week

Leave your email before you copy the prompt.