Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileConfig ¶
type FileConfig struct {
Dir string `yaml:"dir"`
Name string `yaml:"name"`
MaxBytes int64 `yaml:"max_bytes"`
Daily bool `yaml:"daily"`
MaxBackups int `yaml:"max_backups"`
MaxAgeDays int `yaml:"max_age_days"`
Sync SyncPolicy `yaml:"sync"`
}
FileConfig is the shared YAML block for logger and msglog file output.
func (FileConfig) Enabled ¶
func (c FileConfig) Enabled() bool
Enabled reports whether file output is configured (non-empty directory).
func (FileConfig) ToPolicy ¶
func (c FileConfig) ToPolicy(ext string) Policy
ToPolicy converts FileConfig into a runtime Policy. ext is fixed by the caller ("log" or "jsonl") and is not configurable.
type Policy ¶
type Policy struct {
Dir string // output directory
BaseName string // filename prefix, e.g. "seq" / "msg"
Ext string // extension without dot, e.g. "log" / "jsonl"
MaxBytes int64 // size trigger; <=0 disables
Daily bool // UTC day-boundary trigger
MaxBackups int // max retained files (0 = unlimited)
MaxAgeDays int // max age in days (0 = no age-based deletion)
Sync SyncPolicy // durability policy; empty treated as SyncRotate
}
Policy describes runtime rotation rules for one output file. Date and size are OR conditions: either trigger causes a rollover.
type SyncPolicy ¶
type SyncPolicy string
SyncPolicy controls how aggressively writes are flushed to durable storage.
const ( // SyncNone relies on write(2) into the kernel page cache only. // Survives process crash; does not survive power loss. SyncNone SyncPolicy = "none" // SyncRotate fsyncs at each rotation boundary (default). SyncRotate SyncPolicy = "rotate" // SyncPeriodic fsyncs on an external cadence (e.g. observer 1s tick). SyncPeriodic SyncPolicy = "periodic" // SyncEach fsyncs after every Write. Strongest and most expensive. SyncEach SyncPolicy = "each" )
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an io.Writer that rotates on UTC date and/or size. Steady-state Write is lock-free (atomic active pointer + size); the mutex is taken only on the rare rotation path. Writes go straight to *os.File with O_APPEND (no userspace buffering) so a process crash cannot lose a completed write that already returned.
func (*Writer) ActiveName ¶
ActiveName returns the basename of the current active file (for tests/cleanup).