audit

package
v0.7.19 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package audit centralizes audit_log writes so mutating handlers can record their actions with a single call. Write failures are returned so the caller decides whether to fail the operation or carry on (typical webapi call sites swallow the error after a slog.Warn — audit is advisory, not load-bearing).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Log

func Log(ctx context.Context, q *dbgen.Queries, e Entry) error

Log persists e. Returns the underlying DB error if any; does not log internally — the caller's logger already has request context.

Types

type Entry

type Entry struct {
	OrgID      pgtype.UUID
	Actor      string
	Action     string
	TargetKind string
	TargetID   *uuid.UUID
	Detail     map[string]any
}

Entry is one audit event ready to persist.

Zero-value fields map to NULL:

  • Actor="" → NULL (use "system" when the caller is not a user)
  • TargetKind="" → NULL
  • TargetID=nil → NULL
  • Detail=nil → JSON {}

Jump to

Keyboard shortcuts

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