Skip to content

feat: structured admin_action log channel#580

Merged
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
Bilalishaq7:feature/admin-log-channel
Jun 29, 2026
Merged

feat: structured admin_action log channel#580
greatest0fallt1me merged 1 commit into
CalloraOrg:mainfrom
Bilalishaq7:feature/admin-log-channel

Conversation

@Bilalishaq7

Copy link
Copy Markdown
Contributor

closes #561

Description

Implements a dedicated, isolated logging channel for security and administrative event tracking as part of the audit compliance initiative. This PR replaces generic console routing inside administrative routes with a structured, high-context Pino child logger tagged with the channel identity admin_action.

Changes

  • New Middleware (src/middleware/adminLog.ts): Extracted a dedicated child logger instance from the root Pino configuration containing the permanent context flag { channel: 'admin_action' }. Built a lifecycle-aware Express hook tracking route metrics (method, full path, statusCode, durationMs, ip, and userAgent).
  • Identity Context Integration: Correlates actions directly back to the authenticated system operator using res.locals.adminActor populated by the upstream adminAuth cycle.
  • Global Router Attachment (src/routes/admin.ts): Mounted the interceptor at the root administrative route controller, automatically cascading structural monitoring across all present and future nested modules (/apis, /webhooks, /usage, etc.) with zero individual controller overhead.
  • Unit Testing (src/middleware/adminLog.test.ts): Introduced a mock lifecycle environment validating precise execution parameters, response timing traps, and contextual metadata accuracy, ensuring >90% line coverage constraints are explicitly met.
  • Documentation (README.md): Updated codebase reference guides with operational notices tracking the isolated admin_action stream profile for external aggregation profiles (e.g., Datadog, Logstash).

Verification Results

  • Error catalog updates fully synchronized via script engines.
  • Local test runners validating all baseline structures without runtime anomalies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add structured 'admin_action' log channel separate from request logs (v5 patch)

2 participants