logsheet
v1.0.0
Published
Structured log viewer for Express apps with live streaming and SQLite persistence
Maintainers
Readme
logsheet
logsheet is a small Express-friendly logging viewer for runtime flows that need more structure than console output.
It stores log entries in SQLite, serves an HTML viewer for browsing sheets, and streams new entries over SSE for live monitoring.
Install
npm install logsheet better-sqlite3 expressUsage
import express from "express";
import { Logsheet } from "logsheet";
const app = express();
const logsheet = new Logsheet({
basePath: "/logsheet",
publicOrigin: "https://example.com",
});
app.use("/logsheet", logsheet.handler());
const sheet = logsheet.create({
title: "Inbound chat run",
metadata: { chatId: 42 },
});
sheet.log({
group: "ingress",
title: "User message received",
payload: { role: "user", content: "Hello" },
});Open /logsheet to see the list view, then click into a sheet for the live stream.
API
new Logsheet(config?)
dbPath?: stringbasePath?: stringpublicOrigin?: stringstaleSheetMs?: number
logsheet.handler()
Returns an Express router that serves:
GET /list pageGET /:idsheet pageGET /:id/entriesJSON entriesGET /:id/streamSSE streamGET /:id/groupsJSON groups
logsheet.create(options)
Creates a new sheet and returns a Sheet.
title: stringmetadata?: Record<string, unknown>
sheet.log(options)
Appends a log entry and broadcasts it to connected viewers.
title: stringgroup?: stringparentId?: stringlevel?: "info" | "warn" | "error" | "debug"payload?: unknown
sheet.touch()
Updates the sheet timestamp without writing an entry.
sheet.close()
Marks the sheet as closed and emits a close event to viewers.
Development
npm install
npm run buildLicense
MIT
