Help us shape the future of Go! Take the 2026 Go Developer Survey

logtail

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package logtail keeps the most recent lines of a log in memory and streams new ones to followers.

A Tail is an io.Writer, so it can sit next to the log file behind an io.MultiWriter. Writes never block on followers: a follower that falls behind misses lines rather than slowing the logger down.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tail

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

Tail is an io.Writer that remembers the last lines written to it. It is safe for concurrent use.

func New

func New(max int) *Tail

New returns a Tail that keeps the last max lines.

func (*Tail) Follow

func (t *Tail) Follow(ctx context.Context, emit func(line string))

Follow calls emit with every kept line, oldest first, then with each new line until ctx is done. emit is called from Follow's goroutine only.

func (*Tail) Lines

func (t *Tail) Lines(n int) []string

Lines returns up to the last n kept lines, oldest first.

func (*Tail) Write

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

Write splits p into lines, keeps them, and sends them to followers. It always succeeds.

Jump to

Keyboard shortcuts

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