go-auditGo Audit
API Reference

API Reference

Public API for the Auditor type. Every method takes a context.Context and wraps errors with fmt.Errorf for cause inspection.

Complete reference for Go Audit's public API. Every method on the Auditor accepts a context.Context and returns errors wrapped with fmt.Errorf for cause inspection.

Sections

  • Coreaudit.New, NewWithStore, Config, and the Auditor interface.
  • Data Audit APIRecordDataChange, Query, and the DataEntry / AuditLog types.
  • API Audit APIAPI().Record, API().Query, and the APIEntry / AuditAPILog types.
  • Query & FiltersQueryByTransaction, pagination, Purge, Snapshot, and Restore.
  • Dialect Interface — built-in dialects and registering a custom one.
  • Store Interface — the persistence abstraction and how to plug in your own.

The Auditor Interface

type Auditor interface {
    RecordDataChange(ctx context.Context, entry DataEntry) error
    API() APIAuditor
    Query(ctx context.Context, filter DataFilter) ([]AuditLog, error)
    QueryByTransaction(ctx context.Context, txID string) (*TransactionLog, error)
    AutoMigrate(ctx context.Context) error
    Purge(ctx context.Context, before time.Time) (PurgeResult, error)
    Snapshot(ctx context.Context, entityType, entityID string, at time.Time) (map[string]any, error)
    Restore(ctx context.Context, entityType, entityID string, at time.Time) (*RestoreResult, error)
    Config() Config
}

On this page