Documentation
¶
Overview ¶
Package logging provides structured JSON logging with file rotation and compression. Built on log/slog.
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 is an io.WriteCloser that rotates and compresses log files when they exceed a size threshold, and enforces a total disk budget by deleting the oldest compressed files.
func New ¶
func New(cfg config.LoggingConfig, dir string, foreground bool) (*slog.Logger, *RotatingWriter, error)
New creates a slog.Logger that writes JSON to a rotating log file. If foreground is true, also writes to stderr. The log file is created at <dir>/gramaton.log.
func NewRotatingWriter ¶
func NewRotatingWriter(path string, rotateAt, maxTotal int64) (*RotatingWriter, error)
NewRotatingWriter creates a writer that rotates at rotateAt bytes and enforces maxTotal bytes across all log files.
func (*RotatingWriter) Close ¶
func (w *RotatingWriter) Close() error
Close closes the current log file.
Click to show internal directories.
Click to hide internal directories.