Skip to content

Log view

Lines from a log or a source's top list, as a plain table that keeps raw values readable on a phone.

<div id="lv-lines" data-mount="lines"></div>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/log-view.css";

Usage

import { LogView } from "capsomer/react/log-view";

<LogView
  caption="Server errors, last 7 days"
  columns={[
    { key: "path", label: "Path", mono: true, cell: (f) => f.path },
    { key: "status", label: "Status", num: true, cell: (f) => f.status },
    { key: "hits", label: "Hits", num: true, cell: (f) => fmt(f.hits) },
  ]}
  rows={e.failures}
  rowKey={(f) => `${f.path} ${f.status}`}
  truncated={e.truncated}
  note={e.note}
  empty="No request failed with a 5xx."
/>

Examples

No lines

<div id="lv-none" data-mount="none"></div>

API reference

LogView

PropTypeRequiredDoes
captionstringYesWhat the lines are, for the table's name: "Server errors, last 7 days".
showCaptionbooleanShow the caption to the eye too; by default it names the table for a screen reader only, since the panel around it has the heading.
columnsLogColumn<Row>[]Yes
rowsRow[]Yes
rowKey(row: Row) => stringYes
truncatedbooleanThe source sent only its top lines: say so under them.
truncatedNoteReactNode
noteReactNodeA note from the source above the lines ("Sampled at 10%").
emptyLabelstringNo lines: a status and what that means ("No request failed with a 5xx").
emptyReactNodeYes

Parts and data attributes

ClassIs
.cap-logthe root
.cap-log-emptya part
.cap-log-monoa part
.cap-log-notea part

Accessibility

A real table with column headers; the scroll box is a named region with tabindex="0".