Documentation
¶
Overview ¶
Package audit provides a PostMutationHook that logs all mutations to an audit trail (Chronicle). Every INSERT, UPDATE, DELETE is recorded with the table, operation, timestamp, and optionally the changed data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditEntry ¶
type AuditEntry struct {
Timestamp time.Time `json:"timestamp"`
Table string `json:"table"`
Operation string `json:"operation"`
Query string `json:"query,omitempty"`
TenantID string `json:"tenant_id,omitempty"`
Data any `json:"data,omitempty"`
}
AuditEntry represents a single audit log entry.
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook is a PostMutationHook that records all mutations.
func NewLogHook ¶
NewLogHook creates an audit hook that logs to a structured logger.
func (*Hook) AfterMutation ¶
AfterMutation records the mutation in the audit trail.
type LogWriter ¶
LogWriter writes audit entries to a structured logger.
func (*LogWriter) WriteEntry ¶
func (w *LogWriter) WriteEntry(_ context.Context, entry *AuditEntry) error
WriteEntry logs the audit entry.
Click to show internal directories.
Click to hide internal directories.