logging

package
v0.3.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

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.

func (*RotatingWriter) Write

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

Jump to

Keyboard shortcuts

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