g3

audit

import "github.com/afreidah/g3/internal/audit"

Index

Variables

OnEvent is an optional callback invoked on each audit event for metrics integration. Set this to a function that increments a Prometheus counter.

var OnEvent func(event string)

func Log

func Log(ctx context.Context, event string, attrs ...slog.Attr)

Log emits a structured audit log entry at INFO level. The entry includes the audit marker, event name, and request ID from context. Additional attributes are appended after the base fields.

func NewID

func NewID() string

NewID generates a random 16-byte request ID encoded as 32 hex characters.

func RequestID

func RequestID(ctx context.Context) string

RequestID extracts the request ID from the context, or returns an empty string if none is set.

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

WithRequestID returns a new context carrying the given request ID.

Generated by gomarkdoc