uilog

package
v0.0.0-...-de45444 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package uilog plumbs the stdlib log package into both a file and a TUI subscriber so TUI sessions don't have log lines smeared across the altscreen buffer. Headless runs leave the standard logger alone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tap

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

Tap is a writer that fans log output to an underlying sink and to any subscribers that want to render the most recent line in a UI. It also remembers the latest line so a late subscriber can paint immediately, and keeps a bounded ring of recent lines so a logs screen opened later can show scrollback without having tailed from the start.

func New

func New(sink io.Writer) *Tap

New constructs a Tap that writes to sink. Pass io.Discard if you only want the in-memory tap (e.g. tests). The returned Tap is safe for concurrent use.

func (*Tap) Install

func (t *Tap) Install() func()

Install replaces the standard library logger's output with t and clears timestamp/file flags — the file already carries timestamps from the log.Printf callers, and removing the flags keeps the TUI one-liner uncluttered. Returns a restore func.

func (*Tap) Latest

func (t *Tap) Latest() string

Latest returns the most recent complete log line, or "" if none yet.

func (*Tap) Recent

func (t *Tap) Recent() []string

Recent returns a snapshot of the retained log lines, oldest first. The returned slice is a copy, safe to keep and mutate. It's used to seed the logs screen's scrollback when it's opened.

func (*Tap) Subscribe

func (t *Tap) Subscribe() <-chan string

Subscribe returns a channel that receives complete log lines. The channel is buffered; if the consumer can't keep up, lines are dropped (the UI only renders the latest one anyway).

func (*Tap) Write

func (t *Tap) Write(p []byte) (int, error)

Write satisfies io.Writer. It forwards bytes to the sink verbatim and extracts complete lines for subscribers.

Jump to

Keyboard shortcuts

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