HeadlinesBriefing favicon HeadlinesBriefing.com

Go Audit Logging Library Launches

DEV Community •
×

A new Go library called audit tackles a common developer headache: retrofitting audit trails onto existing systems. Author Alexey Abramov built it after seeing audit logic scattered across business code or awkwardly layered on generic loggers. The library provides a clear model for tracking entity changes, addressing the sudden need to answer questions like "who changed this order status?"

The core concept is straightforward: each entity gets a string key like "order:12345," and every change is an explicit event with an author, timestamp, and description. Changes are tracked by field, and sensitive values like payment tokens can be marked as hidden. There's no magic or automatic diffing—developers describe changes explicitly, which avoids unexpected behavior.

audit isn't tied to a specific storage backend. Its Storage interface lets you plug in files, databases, or Kafka. A key integration is with Go's standard slog package, allowing structured logs to automatically become audit events. This keeps audit trails visible in existing log collection systems while providing direct access via methods like `.Logs()` and `.Events()` for building timelines.