auditlog

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package auditlog adds a durable JSON sink beside the process logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure() error

Configure reads audit-log settings and adds the durable sink beside stdout.

func ConfigureWith

func ConfigureWith(config Config) error

ConfigureWith validates config and adds the daily sink to slog's fan-out.

Types

type Config

type Config struct {
	StateDirectory string        `env:"PEEN_STATE_DIR"`
	Directory      string        `env:"PEEN_LOG_DIRECTORY"`
	Retention      time.Duration `default:"336h"           env:"PEEN_LOG_RETENTION"` //nolint:lll // Immutable env tag.
}

Config controls the private rolling audit-log sink.

The default directory sits under the controller's state directory, never under PEEN_CONFIG_DIR. Audit records carry session identifiers, harness digests, and tool outcomes, and PEEN_CONFIG_DIR is mounted into every Docker worker, so an audit directory there would be readable by every session.

Retention is a Go duration and must be a positive whole number of days because files are per UTC day.

type DailyHandler

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

DailyHandler writes JSON records to one UTC-day file and retains recent days.

func NewDailyHandler

func NewDailyHandler(config Config) (*DailyHandler, error)

NewDailyHandler creates today's file immediately so startup failures are detected before the application accepts work.

func (*DailyHandler) Close

func (h *DailyHandler) Close() error

Close releases the active file. It is intended for tests and controlled exit.

func (*DailyHandler) Enabled

func (h *DailyHandler) Enabled(_ context.Context, level slog.Level) bool

Enabled keeps the file trace at debug even when stdout is less verbose.

func (*DailyHandler) Handle

func (h *DailyHandler) Handle(ctx context.Context, record slog.Record) error

Handle writes a structured record to the file for the record's UTC day.

func (*DailyHandler) WithAttrs

func (h *DailyHandler) WithAttrs(attrs []slog.Attr) slog.Handler

WithAttrs returns a derived handler with the attributes on each record.

func (*DailyHandler) WithGroup

func (h *DailyHandler) WithGroup(name string) slog.Handler

WithGroup returns a derived handler with the group on each record.

Jump to

Keyboard shortcuts

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