Documentation
¶
Overview ¶
Package file is a logging sink that writes records to a file as JSON lines, rotating it by size:
file.New(file.Options{Path: "logs/app.log", MaxSize: 50 << 20, Keep: 10})
A rotated file is renamed with the time it was rotated, app-20261111T150405.123.log, and gzipped if Compress is set; the oldest beyond Keep are removed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
// Path is the file written to. Its directory is created if need be.
Path string
// MaxSize is the size in bytes at which the file is rotated. The
// default is 100 MiB; -1 never rotates.
MaxSize int64
// Keep is how many rotated files are kept. The default is 7; -1 keeps
// them all.
Keep int
// Compress gzips rotated files.
Compress bool
// Mode is the new files' permissions. The default is 0o640.
Mode os.FileMode
}
Options configures the sink.
Click to show internal directories.
Click to hide internal directories.