audit

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package audit writes a run's audit log: one JSON object per line, in order, saying what the run did, so a run can be reviewed afterwards.

Index

Constants

View Source
const Version = 1

Version is the log's format version, every event's "v".

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields map[string]any

Fields are an event's fields besides v, seq, t and event.

type Log

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

Log writes events. A nil *Log writes nothing, so callers need not check whether a run keeps one. It is safe to use from more than one goroutine.

func New

func New(w io.Writer) *Log

New returns a log that writes to w, with a new random key for Secret.

func (*Log) Err

func (l *Log) Err() error

Err is the first error writing the log. Nothing is written after it.

func (*Log) Event

func (l *Log) Event(event string, f Fields)

Event writes one event. seq counts from 1; t is RFC 3339 with milliseconds. The other fields follow in name order.

func (*Log) Secret

func (l *Log) Secret(value string) any

Secret is what the log stores where a secret value would go: an HMAC-SHA-256 of it, keyed with the log's key, so two secrets in one run can be compared but a short one can't be guessed.

Jump to

Keyboard shortcuts

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