Documentation
¶
Overview ¶
Package logring keeps the panel's last log records in memory and lets the owner change the level while it runs. Handler wraps the process's slog handler: every record the current level lets through goes to the ring and on to the wrapped handler. The ring is for the panel's own diagnostics (the panel_logs RPC and MCP tool); it holds raw records, so a reader must scrub them (internal/panel/ops does) before they leave the process.
Index ¶
Constants ¶
const DefaultCapacity = 5000
DefaultCapacity is how many records the ring keeps.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Attr ¶
type Attr struct{ Key, Value string }
Attr is one attribute of a record, its value rendered as text and cut.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler is a slog.Handler that records into a Ring and forwards to the handler it wraps.
func NewHandler ¶
NewHandler wraps next. level decides what is recorded and forwarded; next must not filter by a stricter level of its own (build it with the same LevelVar).
type Record ¶
type Record struct {
Seq int64 // 1, 2, 3 ...: grows with every record, never reused; the cursor of a read
Time time.Time
Level slog.Level
Message string
Component string // attribute "component", else the word before the first ": " of the message ("health: prune" -> "health")
Code string // attribute "code"
RequestID string // attribute "request_id", else the id of the request context
Attrs []Attr
}
Record is one logged record as the ring keeps it.
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
Ring is a fixed-size buffer of the latest records.
func New ¶
func New(w io.Writer, format string, level slog.Level, capacity int) (*slog.Logger, *Ring, *slog.LevelVar)
New builds the process logger: text or JSON ("json") records to w at a level the owner can change later, kept in a ring of capacity records. The level var starts at level.