Documentation
¶
Overview ¶
Package logs is the v1.6 phase 6 in-UI log tail. A small ring buffer captures every slog line the daemon emits; the SSE handler streams the backlog + live tail to an admin-gated UI page at /admin/logs.
Implementation as a slog.Handler that wraps the daemon's default handler so structured log output still flows to stderr but ALSO fans out into the ring + every subscribed SSE consumer.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer is the shared ring + fan-out hub. Constructed once in cli/serve.go + installed as a wrapping slog.Handler.
func New ¶
func New() *Buffer
New returns an empty Buffer. Wire via Handler(inner) to install as the slog default; Handler.HTTP returns the SSE endpoint.
func (*Buffer) Handler ¶
Handler returns a slog.Handler that writes records to `inner` (typically stderr's TextHandler) AND captures them into the ring. Pass nil for inner to capture only — the daemon still gets the stderr stream because the wrapper is chained after it.
func (*Buffer) StreamHandler ¶
func (b *Buffer) StreamHandler() http.HandlerFunc
StreamHandler returns the GET /admin/logs/stream SSE handler. MUST be wrapped by an admin-only gate before mounting.
func (*Buffer) Subscribe ¶
Subscribe returns a channel of live log lines + the current backlog snapshot (filtered by ?since cursor). Always called via Defer-Unsubscribe in the SSE handler.
func (*Buffer) Unsubscribe ¶
Unsubscribe drops + closes the subscriber. Idempotent.
type Line ¶
type Line struct {
ID uint64 `json:"id"`
Time time.Time `json:"time"`
Level string `json:"level"`
Msg string `json:"msg"`
Attrs string `json:"attrs,omitempty"` // flattened "k=v k=v" for terse render
Source string `json:"source,omitempty"`
}
Line is one captured log entry in the buffer + SSE wire format.