audit — audit-trail event capture
import "github.com/downsized-devs/sdk-go/audit"
Stability: Stable — see STABILITY.md
Captures domain events with the request/user context already on context.Context. Persistent log stream separate from operational logger lines.
Features
Capture / Record for fire-and-forget event capture
- Auto-attaches
requestId, userId from appcontext and auth info from auth
- Single
Interface for easy mocking
Installation
go get github.com/downsized-devs/sdk-go/audit
Quick Start
a := audit.Init(audit.Config{})
a.Capture(ctx, audit.Collection{
Resource: "user",
Action: "update",
Before: oldUser,
After: newUser,
})
API Reference
| Symbol |
Signature |
Init |
func Init(cfg Config) Interface |
Interface.Capture |
(ctx, Collection) |
Interface.Record |
(ctx, Collection) |
Collection |
Resource/action/before/after payload (see audit/entity.go). |
Error Handling
Capture/Record do not return errors — failures are logged but never block business logic.
Dependencies
Testing
go test ./audit/...
Contributing
See CONTRIBUTING.md.
logger — operational logs vs durable audit events.
appcontext — provides request/user metadata.
auth — provides current-user info.