Documentation
¶
Overview ¶
Package auditlog adds a durable JSON sink beside the process logger.
Index ¶
- func Configure() error
- func ConfigureWith(config Config) error
- type Config
- type DailyHandler
- func (h *DailyHandler) Close() error
- func (h *DailyHandler) Enabled(_ context.Context, level slog.Level) bool
- func (h *DailyHandler) Handle(ctx context.Context, record slog.Record) error
- func (h *DailyHandler) WithAttrs(attrs []slog.Attr) slog.Handler
- func (h *DailyHandler) WithGroup(name string) slog.Handler
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 ¶
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 ¶
Enabled keeps the file trace at debug even when stdout is less verbose.
func (*DailyHandler) Handle ¶
Handle writes a structured record to the file for the record's UTC day.