mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 13:52:20 +00:00
feat(admin): app-log preview surfaces last 1h of structured events with filter + JSON inspector
Wires the in-memory ring buffer (`src/lib/logging/in-memory-buffer.ts`) into `transports.emitEvent()` so every wide event that survives the sampler also lands in a 500-entry per-process buffer. Adds the `app-logs` admin section slug, the renderer case, and the route entry exports needed for the new section component to mount. The buffer is volatile and per-process — a worker-only event won't show up in the web buffer, and a restart drops everything. The section header copy spells that out so admins know to keep Loki configured for durable diagnostics. Egress through `/api/admin/app-logs` runs every event through `redactSecrets()` so a stray Bearer / hlk_ / sk- token in an `error.message` never leaks to the admin UI; storage stays raw to keep the diagnostic value when shipped to Loki. The companion buffer + transports tests live under `src/lib/logging/__tests__/in-memory-buffer.test.ts` and `transports-buffer.test.ts` (committed separately as part of the buffer scaffolding). The route-level tests in `src/app/api/admin/app-logs/__tests__/route.test.ts` cover newest- first ordering, traceId / level / action filters, the `limit` cap, secret redaction on egress, and the Zod-rejected invalid `level` case. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
226cac4c02
commit
4cc3d8d45e
4 files changed
+31
-1
No files matched your search
@@ -17,6 +17,7 @@ import type { JSX } from "react";
|
||||
import { useAuth } from "@/hooks/use-auth";
|
||||
import { useTranslations } from "@/lib/i18n/context";
|
||||
import { ApiTokenOverviewSection } from "@/components/admin/api-token-overview-section";
|
||||
import { AppLogPreviewSection } from "@/components/admin/app-log-preview-section";
|
||||
import { BackupsSection } from "@/components/admin/backups-section";
|
||||
import { DangerZoneSection } from "@/components/admin/danger-zone-section";
|
||||
import { FeedbackInboxSection } from "@/components/admin/feedback-inbox-section";
|
||||
@@ -127,6 +128,15 @@ export function AdminSectionRenderer({
|
||||
<LoginOverviewSection />
|
||||
</SectionFrame>
|
||||
);
|
||||
case "app-logs":
|
||||
return (
|
||||
<SectionFrame
|
||||
title={t("admin.section.app-logs.title")}
|
||||
subtitle={t("admin.section.app-logs.subtitle")}
|
||||
>
|
||||
<AppLogPreviewSection />
|
||||
</SectionFrame>
|
||||
);
|
||||
case "backups":
|
||||
return (
|
||||
<SectionFrame
|
||||
|
||||
Reference in new issue
Block a user