{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package audit\n\n## Types\n\n```go\ntype Event struct {\n\tTimestamp time.Time      `json:\"timestamp\"`\n\tType      EventType      `json:\"type\"`\n\tAction    string         `json:\"action\"`\n\tActor     string         `json:\"actor,omitempty\"`\n\tResource  string         `json:\"resource,omitempty\"`\n\tDetail    string         `json:\"detail,omitempty\"`\n\tSourceIP  string         `json:\"source_ip,omitempty\"`\n\tSuccess   bool           `json:\"success\"`\n\tMetadata  map[string]any `json:\"metadata,omitempty\"`\n}\n```\nEvent is a single audit log entry.\n\n```go\ntype EventType string\n```\nEventType classifies security-relevant audit events.\n\n```go\nconst (\n\tEventAuth         EventType = \"auth\"\n\tEventAuthFailure  EventType = \"auth_failure\"\n\tEventAdminOp      EventType = \"admin_op\"\n\tEventEscalation   EventType = \"escalation\"\n\tEventDataAccess   EventType = \"data_access\"\n\tEventConfigChange EventType = \"config_change\"\n\tEventComponentOp  EventType = \"component_op\"\n)\n```\n\n```go\ntype Logger struct {\n\t// contains filtered or unexported fields\n}\n```\nLogger records security-relevant audit events as structured JSON.\n\n```go\nfunc NewLogger(w io.Writer) *Logger\n```\nNewLogger creates an AuditLogger that writes JSON events to the given writer. If w is nil, it defaults to os.Stdout.\n\n```go\nfunc (l *Logger) Log(_ context.Context, event Event)\n```\nLog records an audit event. It is safe for concurrent use.\n\n```go\nfunc (l *Logger) LogAdminOp(ctx context.Context, actor, action, resource, detail string)\n```\nLogAdminOp records an administrative operation.\n\n```go\nfunc (l *Logger) LogAuth(ctx context.Context, actor, sourceIP string, success bool, detail string)\n```\nLogAuth records an authentication event.\n\n```go\nfunc (l *Logger) LogComponentOp(ctx context.Context, actor, action, componentID, detail string, success bool)\n```\nLogComponentOp records a dynamic component lifecycle operation.\n\n```go\nfunc (l *Logger) LogConfigChange(ctx context.Context, actor, resource, detail string)\n```\nLogConfigChange records a configuration change event.\n\n```go\nfunc (l *Logger) LogDataAccess(ctx context.Context, actor, resource, detail string)\n```\nLogDataAccess records a data access event.\n\n```go\nfunc (l *Logger) LogEscalation(ctx context.Context, actor, action, detail string, success bool)\n```\nLogEscalation records a privilege escalation event.\n\n","path":"github.com/GoCodeAlone/workflow/audit","name":"audit","synopsis":"","isRedistributable":true}
