@davstack/logs-server

中文文档
2.10.0发布于 2026/06/06MITTypeScriptES Module近 30 天下载 1.4万

Local Sentry-shaped telemetry sink (logs + traces): ingest envelopes over HTTP, persist to per-repo SQLite. Read with sqlite3 against the logs table (kind discriminates log vs span; flat attrs column).

原始使用文档
文档目录5 节
  1. Why
  2. Install & setup (1 min)
  3. Usage Example
  4. Schema
  5. Docs

@davstack/logs-server

Local Sentry-shaped app -> sqlite telemetry sink (logs and traces).

Why

  • E2E traceability. Frontend + backend + workers POST to the same .davstack/logs/default.db; trace_id follows requests across services. Logs, trace spans, and error events land in one table, discriminated by a kind column ('log' | 'span' | 'event').
  • Zero infra. Integrates into existing sentry logger client for auto-instrumentation and low effort setup. Set tracesSampleRate and spans flow into the same sink as logs — no extra wiring.
  • Optimized for Agents. Compact one-row-per-line by default — coding agents read it without grouping passes.

Install & setup (1 min)

  1. Recommended: scaffold with davstack init
pnpx @davstack/init

(cd to your project repo first - logs-server is scoped to codebase)

  1. Set up local sink — in dev, point your existing Sentry DSN at the daemon:
Sentry.init({dsn: IS_DEV ? "http://[email protected]:5181/1" : import.meta.env.VITE_SENTRY_DSN })

(see full setup guide before usage: setup.md)

Usage Example

  1. Start server
davstack start

(more info: davstack tui)

  1. Add logs to app, or use autoinstumentation.
logger.debug("user clicked save", { user_id: 42, run_id: "r-99" })

(more info: writing-logs.md)

  1. Run repo with --db (optional) — scopes this session's logs to its own DB
vitest-server run --db=reorder-bug src/reorder.test.ts   # → .davstack/logs/reorder-bug.db (default: default.db)

notes:

  • Davstack runner is recommended (vitest-server), however regular pnpm dev still captures logs
  • --db usage is recommended, however without it logs still land in default.db.

(more info: transmitter-wiring.md)

  1. Query logs with sqlite3.
sqlite3 -header -column .davstack/logs/default.db "
  SELECT ts, msg, attrs->>'user_id' AS user_id
  FROM logs
  WHERE data->>'body' LIKE '%clicked save%'
  ORDER BY ts;
"

Result:

ts          msg                user_id
----------  -----------------  -------
1716480923  user clicked save  42
  1. Query trace spans — kind='span' rows have a real duration_ms column, so the slowest spans sort in plain SQL. op/status/parent_span_id are flattened into attrs.
sqlite3 -header -column .davstack/logs/default.db "
  SELECT msg, duration_ms,
         attrs->>'op'     AS op,
         attrs->>'status' AS status
  FROM logs
  WHERE kind = 'span'
  ORDER BY duration_ms DESC
  LIMIT 10;
"

(Logs and spans share the trace_id column, so a single WHERE trace_id = ? slices the full request timeline across both.)

  1. Query error events — kind='event' rows are real exceptions (Sentry.captureException, unhandled errors, React error boundaries). The full stacktrace is in data; exception_type/mechanism are flattened into attrs.
sqlite3 -header -column .davstack/logs/default.db "
  SELECT ts, msg,
         attrs->>'exception_type' AS type,
         attrs->>'function'       AS fn,
         attrs->>'filename'       AS file
  FROM logs
  WHERE kind = 'event'
  ORDER BY ts DESC
  LIMIT 10;
"

Schema

One logs table per session DB. Key columns:

columnlogsspans (kind='span')events (kind='event')
kind'log''span''event'
tslog timestampspan start_timestampevent timestamp
duration_msNULL(timestamp - start_timestamp) * 1000NULL
msglog bodyspan description || op (root: tx name)"{type}: {value}" (exc) || message
levelOTel level''event level (error/fatal/warning/info)
dataverbatim log itemverbatim span / transaction-trace objectverbatim event (full exception/stacktrace)
attrsflat attrs (unwrapped)flat span data + op/status/parent_span_id/description/duration_msexception_type/mechanism/handled + top in_app frame

A transaction event expands to one row per span: the root (from contexts.trace) plus one per spans[] child. An error/message event (Sentry.captureException, captureMessage, unhandled errors, React error boundaries) becomes one kind='event' row — the full stacktrace lives verbatim in data, and its trace_id correlates it with the logs/spans of the same request.

Docs

版本与发布记录

@davstack/logs-server 共发布 22 个版本,首次发布于 2026/05/26;过去 12 个月发布了 22 个版本。

版本发布日期距今
2.10.0latest2026/06/065 个月前
2.9.12026/06/045 个月前
2.9.02026/06/045 个月前
2.8.02026/06/045 个月前
2.7.22026/06/025 个月前
2.7.12026/06/025 个月前

关于 @davstack/logs-server 的常见问题

@davstack/logs-server 是什么?

Local Sentry-shaped telemetry sink (logs + traces): ingest envelopes over HTTP, persist to per-repo SQLite. Read with sqlite3 against the logs table (kind discriminates log vs span; flat attrs column).

如何安装 @davstack/logs-server?

在项目目录运行 npm install @davstack/logs-server,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 logs-server,可以用 npx logs-server 直接运行。

@davstack/logs-server 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@davstack/logs-server 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@davstack/logs-server 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@davstack/logs-server 可以商用吗?

@davstack/logs-server 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@davstack/logs-server 的下载量有多少?

根据 npm 官方下载统计,@davstack/logs-server 在 2026/10/12 – 2026/11/10 这 30 天内被下载 13,503 次,日均约 450 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@davstack/logs-server 还在维护吗?

最新版本 2.10.0 发布于 2026/06/06(5 个月前);至今共发布 22 个版本,其中过去 12 个月发布了 22 个;首次发布于 2026/05/26。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。