Documentation
¶
Overview ¶
Package log provides the two halves of loom's logging model (DESIGN.md §6): a lock-free, non-blocking hot-path event Ring drained off the data plane, and an async leveled Logger for control/diagnostic output. The data plane must never block on logging, so the hot path only ever touches the Ring.
Index ¶
Constants ¶
const ( // EventSent records that one packet was sent (Value = bytes). EventSent uint16 = iota + 1 )
Event codes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Drainer ¶
type Drainer struct {
// contains filtered or unexported fields
}
Drainer moves events from a Ring to a Handler off the data plane. It polls the ring, draining it fully each pass, and does a final drain on shutdown.
func NewDrainer ¶
NewDrainer returns a Drainer for ring calling h per event. poll <= 0 uses 1ms.
type Event ¶
Event is a fixed-size, pointer-free hot-path record so pushing it allocates nothing and copies cheaply.
type Handler ¶
type Handler func(Event)
Handler consumes a drained event. It runs off the hot path, so it may do real work (format, ship, aggregate).
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is an async leveled logger for control/diagnostic output. Log calls format a line and hand it to a background writer via a buffered channel; if the channel is full the line is dropped and counted, so logging never blocks the caller. It is NOT for the data-plane hot path — that uses Ring.
func (*Logger) Close ¶
func (l *Logger) Close()
Close flushes buffered lines and stops the writer. The Logger must not be used after Close.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring is a single-producer/single-consumer lock-free ring buffer. The data plane (one worker) Pushes; a drainer Pops. Push never blocks: when the ring is full it drops the event and increments a counter. Capacity is rounded up to a power of two.
func NewRing ¶
NewRing returns a Ring with capacity >= size (rounded up to a power of two, minimum 2).