tuilog

package
v0.0.37 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package tuilog provides a custom slog.Handler that captures log entries into an in-memory ring buffer and optionally sends warn/error entries to a channel for TUI toast display.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Time    time.Time
	Level   slog.Level
	Message string
	Attrs   string // pre-formatted key=value pairs
}

Entry is a single captured log record.

func (Entry) String

func (e Entry) String() string

String renders the entry as a single human-readable line.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is a slog.Handler that writes to a Store and pushes warn/error entries onto a channel for TUI toast display.

func NewHandler

func NewHandler(store *Store, toasts chan<- ToastEntry) *Handler

NewHandler creates a Handler that captures to the given store. Entries at or above toastLevel are also sent to the toasts channel. The channel should be buffered to avoid blocking the caller.

func (*Handler) Enabled

func (h *Handler) Enabled(_ context.Context, level slog.Level) bool

func (*Handler) Handle

func (h *Handler) Handle(_ context.Context, r slog.Record) error

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a thread-safe ring buffer of log entries.

func NewStore

func NewStore() *Store

NewStore creates a Store with the default capacity.

func (*Store) Append

func (s *Store) Append(e Entry)

Append adds an entry to the store, evicting the oldest if at capacity.

func (*Store) Len

func (s *Store) Len() int

Len returns the current number of stored entries.

func (*Store) Snapshot

func (s *Store) Snapshot() []Entry

Snapshot returns a copy of all entries (oldest first).

type ToastEntry

type ToastEntry struct {
	Level   slog.Level
	Message string
}

ToastEntry is sent over the toast channel for warn/error log entries.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL