2.3 KiB
2.3 KiB
F-078 — Implementer evidence
What was implemented
Backend (project/src/)
infrastructure/logging/log-broadcaster.ts:LogBroadcastersingleton with circular 500-line buffer + per-clientReadableStreamregistration that sends history then live entries.infrastructure/logging/logger.ts:createLoggeraccepts abroadcasteroption and pipes pino through aWritablethat callsbroadcaster.addEntry().infrastructure/http/server.ts: instantiatesgetLogBroadcaster()and passes to logger.modules/security/api/security.routes.ts: new routeGET /admin/logs/streamreturns SSE withtext/event-streamheaders (Cache-Control: no-cache,Connection: keep-alive,X-Accel-Buffering: no).app/build-app.ts: passesbroadcastertoregisterSecurityRoutes.
Frontend (project/apps/admin/src/)
components/ServerLogViewer.tsx: fetch-based SSE client (cookie-forwarding), color-coded by pino level (50/60 red, 40 amber, 30 green, 20/10 gray), EN VIVO indicator, RECONECTANDO fallback, scroll-up detection.app/(dashboard)/logs/page.tsx: admin page hostingServerLogViewer.lib/permissions.ts: new nav itemLogs(admin-only viaaudit.read).
Files changed
project/src/infrastructure/logging/log-broadcaster.ts(new)project/src/infrastructure/logging/logger.ts(broadcaster option)project/src/infrastructure/http/server.ts(wiring)project/src/modules/security/api/security.routes.ts(SSE route)project/src/app/build-app.ts(deps wiring)project/apps/admin/src/components/ServerLogViewer.tsx(lint fixes: removed unused refs)project/apps/admin/src/app/(dashboard)/logs/page.tsx(new)project/apps/admin/src/lib/permissions.ts(nav entry)
Validation
npx tsc --noEmit -p apps/admin/tsconfig.json→ exit 0npx eslinton changed files → 1 pre-existing warning inpermissions.ts(can(role, permission)unused arg) NOT introduced by this change../scripts/verify.sh→ exit 0.
Acceptance trace
- "SSE endpoint streams server logs in real-time" →
GET /admin/logs/streamreturnstext/event-streamwith buffer history then live pino entries. - "Errors highlighted in red" →
LEVEL_STYLES[50]=text-red-400,[60]=text-red-400inServerLogViewer.tsx. - "Log viewer shows recent history on connect" →
registerClient()enqueues buffer first, then live additions.