Documentation
¶
Overview ¶
Package errorlog captures recent WARN/ERROR slog records into a bounded in-memory ring buffer for display in the admin UI. It is intentionally narrow: no persistence, no search, no time-range queries. Deeper investigation belongs in an external log aggregator.
Index ¶
Constants ¶
const DefaultCapacity = 1000
DefaultCapacity is the ring-buffer size used when NewStore is called with capacity <= 0.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attr ¶
Attr is a key/value pair from the record (or surrounding handler scope). Values are pre-rendered to strings so the UI does not need to know about slog.Value kinds.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler wraps a delegate slog.Handler and additionally captures records whose level is >= Level into Store. The delegate handler is always consulted (and invoked if it enables the record) so the existing JSON stderr output keeps working unchanged.
The delegate's own level filter determines what is written to stderr; Level controls what is captured into the ring buffer and may be more permissive.
func NewHandler ¶
NewHandler returns a Handler that forwards to delegate and captures records at level >= captureLevel into store.
func (*Handler) Enabled ¶
Enabled reports whether either the delegate or the capture path wants the record. Without this, slog short-circuits WARN records when the delegate is set to ERROR, starving the ring buffer.
func (*Handler) Handle ¶
Handle forwards the record to the delegate and, if the record meets the capture threshold, appends a flattened copy to the ring buffer.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a bounded ring buffer of captured entries. Writes are non-blocking; the oldest entry is overwritten when the buffer is full.
Store is safe for concurrent use.
func NewStore ¶
NewStore returns a ring buffer sized to capacity. Non-positive values fall back to DefaultCapacity.