Skip to content

refactor: consolidate audit logging into internal/audit provider#541

Merged
lakhansamani merged 2 commits intomainfrom
feat/audit-log-provider-refactor
Apr 3, 2026
Merged

refactor: consolidate audit logging into internal/audit provider#541
lakhansamani merged 2 commits intomainfrom
feat/audit-log-provider-refactor

Conversation

@lakhansamani
Copy link
Copy Markdown
Contributor

Summary

Replaces two duplicate audit log helpers with a single audit.Provider following the project's standard provider pattern (Dependencies + New() + Provider interface).

Before: Duplicate logAuditEvent() methods and AuditLogOpts structs in both internal/graphql/ and internal/http_handlers/

After: Single internal/audit/ package with Provider interface injected as a dependency

Changes

  • Create internal/audit/provider.go with Provider interface, Event struct, and async LogEvent implementation
  • Add AuditProvider audit.Provider to graphql.Dependencies and http_handlers.Dependencies
  • Initialize audit.Provider in cmd/root.go and pass through to both providers
  • Update all 32 call sites across 29 files to use audit.Event
  • Delete internal/graphql/audit_log_helper.go and internal/http_handlers/audit_log_helper.go

Ref: RFC #505 — Structured Audit Log System (audit logger service section)

Test plan

  • go build ./... passes
  • TEST_DBS=sqlite — 8/8 audit log tests pass

@lakhansamani lakhansamani changed the base branch from feat/audit-log to main April 3, 2026 08:27
@lakhansamani lakhansamani force-pushed the feat/audit-log-provider-refactor branch from 24bb5cc to 6eb3bf4 Compare April 3, 2026 08:38
Replace two duplicate audit log helpers (graphql/audit_log_helper.go
and http_handlers/audit_log_helper.go) with a single audit.Provider
in internal/audit/ following the project's standard provider pattern.

- Create internal/audit/provider.go with Provider interface + LogEvent
- Inject AuditProvider into graphql.Dependencies and http_handlers.Dependencies
- Initialize audit provider in cmd/root.go
- Update all 32 call sites across 29 files to use audit.Event
- Delete the two old helper files
- Callers now extract IP/UserAgent and pass in Event struct directly
@lakhansamani lakhansamani force-pushed the feat/audit-log-provider-refactor branch from 6eb3bf4 to 35053fa Compare April 3, 2026 08:48
@lakhansamani lakhansamani merged commit d210298 into main Apr 3, 2026
@lakhansamani lakhansamani deleted the feat/audit-log-provider-refactor branch April 3, 2026 08:54
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.

1 participant