audit

package
v0.50.54 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package audit provides a rotating log writer for audit trails.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RotatingWriter

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

RotatingWriter implements io.Writer with size-based rotation.

func NewRotatingWriter

func NewRotatingWriter(path string, maxSize int64, maxAge time.Duration) (*RotatingWriter, error)

NewRotatingWriter opens or creates the log file at path. It rotates when the file exceeds maxSize and deletes rotated files older than maxAge.

func (*RotatingWriter) Close

func (w *RotatingWriter) Close() error

Close closes the underlying file.

func (*RotatingWriter) StartCleanup

func (w *RotatingWriter) StartCleanup(ctx context.Context)

StartCleanup runs a background goroutine that deletes rotated files older than maxAge. It checks every hour and stops when ctx is cancelled.

func (*RotatingWriter) Write

func (w *RotatingWriter) Write(p []byte) (n int, err error)

Write appends p to the log file. It is safe for concurrent use. If the write would exceed maxSize, the file is rotated first.

Jump to

Keyboard shortcuts

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