audit

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	UserID    uint
	Action    string
	ModelType string
	ModelID   uint
	OldValues map[string]interface{}
	NewValues map[string]interface{}
	Metadata  map[string]interface{}
}

Entry holds the data for a single audit log record.

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger writes audit log entries to the database.

func NewLogger

func NewLogger(db *gorm.DB) *Logger

NewLogger creates a new audit Logger backed by the given database connection.

func (*Logger) Find

func (l *Logger) Find(query string, args ...interface{}) ([]models.AuditLog, error)

Find returns audit log entries matching the given conditions, ordered newest first. Conditions use GORM Where syntax: Find("user_id = ?", 42).

func (*Logger) ForModel

func (l *Logger) ForModel(modelType string, modelID uint) ([]models.AuditLog, error)

ForModel returns all audit log entries for a specific model type and ID.

func (*Logger) Log

func (l *Logger) Log(e Entry) error

Log persists an audit entry to the database.

Jump to

Keyboard shortcuts

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