universal-logs
v0.1.0
Published
CLI and runtime helpers for exposing local log endpoints and reading them from coding agents.
Readme
universal-logs
universal-logs is a small npm package with two parts:
- A CLI that reads logs from HTTP endpoints or React Native Metro
- Runtime helpers that expose HTTP log snapshots from Node or Electron apps
CLI
Run against a named target from config:
npx universal-logs electron --limit 80Run against an explicit endpoint:
npx universal-logs --endpoint http://127.0.0.1:6973/logs --limit 80Read live React Native logs from Metro:
npx universal-logs metro --app com.fieldy --limit 80 --timeout 5000List configured targets:
npx universal-logs listConfig
Create universal-logs.config.json in your repo:
{
"targets": {
"electron": {
"endpoint": "http://127.0.0.1:6973/logs"
},
"api": {
"endpoint": "http://127.0.0.1:6971/logs"
},
"native": {
"provider": "metro",
"metroUrl": "http://127.0.0.1:8081",
"app": "com.fieldy",
"timeoutMs": 5000
}
}
}The CLI also reads package.json from a top-level universalLogs field.
Configured Metro targets work like any other target:
npx universal-logs native --limit 80Metro is a live stream, not a snapshot. The CLI listens for new console events until it reaches --limit or --timeout.
Runtime
Expose a log buffer from a Node process:
import {
createConsoleMirror,
createLogBuffer,
startHttpLogEndpoint,
} from "universal-logs/runtime"
const buffer = createLogBuffer({ limit: 500 })
createConsoleMirror({ buffer, source: "api" })
await startHttpLogEndpoint({
buffer,
port: 6971,
service: "api",
})Attach renderer logs in Electron:
import {
attachElectronRendererConsoleMirror,
createLogBuffer,
} from "universal-logs/runtime"
const buffer = createLogBuffer()
app.on("browser-window-created", (_event, window) => {
attachElectronRendererConsoleMirror({
buffer,
webContents: window.webContents,
})
})Metro support does not need a runtime helper. It attaches to Metro's inspector endpoints at /json/list and /json, then listens for Runtime.consoleAPICalled over CDP.
Response shape
GET /logs?limit=100 returns:
{
"service": "electron",
"limit": 100,
"total": 42,
"entries": [
{
"timestamp": "2026-04-03T10:00:00.000Z",
"level": "info",
"source": "desktop:renderer",
"message": "hello"
}
]
}