logstore

package
v1.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package logstore owns byte bounds and deterministic retention for process logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RotateAtStartup

func RotateAtStartup(path string, policy Policy) error

RotateAtStartup bounds existing bootstrap/crash output, moves the latest non-empty process output into retention, and leaves the current inode empty for descriptors the service manager already opened.

Types

type Policy

type Policy struct {
	MaxBytes int64
	Backups  int
}

Policy defines the hard size of the current file and how many same-sized backups are retained. Backups use the suffixes .1 (newest) through .N.

func BootstrapPolicy

func BootstrapPolicy() Policy

func LifecyclePolicy

func LifecyclePolicy() Policy

Log bounds have one owner so lifecycle, managed dependency, and bootstrap sinks cannot silently drift apart. Functions return values so callers cannot mutate process-wide policy.

func ManagedServerPolicy

func ManagedServerPolicy() Policy

type RotatingWriter

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

RotatingWriter is a concurrent-safe, byte-bounded writer. Rotation copies the current file into the backup chain and truncates the current inode in place. Keeping the inode is important for service managers and subprocesses that may still hold an open descriptor for the current path.

func Open

func Open(path string, policy Policy) (*RotatingWriter, error)

Open opens path for append and immediately brings any pre-existing files under policy. Directories are created with the project-standard mode.

func (*RotatingWriter) Close

func (w *RotatingWriter) Close() error

Close closes the writer. It is safe to call more than once.

func (*RotatingWriter) RotateNow

func (w *RotatingWriter) RotateNow() error

RotateNow snapshots a non-empty current file and truncates its inode in place. It is used at process start for the small pre-logger crash sink.

func (*RotatingWriter) Write

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

Write appends all of p, rotating before each chunk that would exceed the current-file bound. A single oversized write is split across rotations, so no file exceeds MaxBytes even transiently after Write returns.

Jump to

Keyboard shortcuts

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