audit

package
v0.0.0-...-b25413d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeJSON

func NormalizeJSON(b []byte) string

NormalizeJSON formats and sorts keys so that JSON diffs are stable.

func UnifiedDiff

func UnifiedDiff(beforeJSON, afterJSON []byte) (unified string, added, removed int)

UnifiedDiff returns a unified diff of two JSON documents and counts of added and removed key lines. Only lines containing '":' (JSON key lines) are counted as changes in the added and removed totals.

Types

type Recorder

type Recorder struct {
	DB          *sql.DB
	Dialect     ormdriver.Dialect
	TablePrefix string
}

Recorder writes audit logs to the database.

func (*Recorder) Write

func (r *Recorder) Write(ctx context.Context, actor string, old, new *registry.FieldMeta) error

Write records a single field change.

func (*Recorder) WriteAction

func (r *Recorder) WriteAction(ctx context.Context, actor, action, targetVer, diffSummary string) error

WriteAction inserts a generic audit log entry for high level actions like snapshot creation or rollback. The diffSummary may be any short description such as "+2 -0".

func (*Recorder) WriteJSON

func (r *Recorder) WriteJSON(ctx context.Context, actor, action string, payload any) error

WriteJSON writes an audit log entry with arbitrary JSON payload.

func (*Recorder) WriteTableJSON

func (r *Recorder) WriteTableJSON(ctx context.Context, actor, action, table string, payload any) error

WriteTableJSON writes an audit log entry for a specific table with the given payload.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL