mirror of
https://github.com/PrivateCaptcha/PrivateCaptcha.git
synced 2026-05-07 21:40:51 -05:00
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
package common
|
|
|
|
import "time"
|
|
|
|
type AuditLogAction int
|
|
|
|
const (
|
|
AuditLogActionUnknown AuditLogAction = iota
|
|
AuditLogActionCreate
|
|
AuditLogActionUpdate
|
|
AuditLogActionDelete
|
|
AuditLogActionSoftDelete
|
|
AuditLogActionRecover
|
|
AuditLogActionLogin
|
|
AuditLogActionLogout
|
|
AuditLogActionAccess
|
|
// Add new fields _above_
|
|
AUDIT_LOG_ACTIONS_COUNT
|
|
)
|
|
|
|
func (ala AuditLogAction) String() string {
|
|
switch ala {
|
|
case AuditLogActionCreate:
|
|
return "create"
|
|
case AuditLogActionUpdate:
|
|
return "update"
|
|
case AuditLogActionDelete:
|
|
return "delete"
|
|
case AuditLogActionSoftDelete:
|
|
return "softdelte"
|
|
case AuditLogActionRecover:
|
|
return "recover"
|
|
case AuditLogActionLogin:
|
|
return "login"
|
|
case AuditLogActionLogout:
|
|
return "logout"
|
|
case AuditLogActionAccess:
|
|
return "access"
|
|
default:
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
// NOTE: alternative design could have been an interface. It will yield a smaller memory footprint for DTOs inside the
|
|
// channel/buffers of AuditLog in DB. However, current "flat" struct is much more convenient and has smaller total loc.
|
|
// Also the total memory benefit is not projected to be so huge because these are relatively rare one-off events.
|
|
type AuditLogEvent struct {
|
|
UserID int32
|
|
Action AuditLogAction
|
|
EntityID int64
|
|
TableName string
|
|
SessionID string
|
|
OldValue interface{}
|
|
NewValue interface{}
|
|
Timestamp time.Time
|
|
}
|