tail

package
v3.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Follow

func Follow(ctx context.Context, out chan<- string, logFormatter LogFormatter, fileName string,
	count int, group *sync.WaitGroup,
) error

Follow sends to the channel each new line from the file as it grows.

func TailN

func TailN(ctx context.Context, logFormatter LogFormatter, fileName string,
	count int,
) (<-chan string, error)

TailN calls sends last count lines of the file to the channel.

Types

type ColorPicker

type ColorPicker func() color.Color

ColorPicker returns a color.

func DefaultColorPicker

func DefaultColorPicker() ColorPicker

DefaultColorPicker create a color picker to get a color from a default colors set.

type Follower

type Follower interface {
	// Follow reads the last `lines` lines from the log file and prints them.
	// It continues to follow the log file, printing new lines as they are added,
	// keeps working until context `Done`.
	Follow(ctx context.Context, lines int) (<-chan string, error)

	// Wait waits for the follower to finish processing.
	Wait()
}

Follower is an interface for reading and following log files.

func NewTailFollower

func NewTailFollower(fileName string) Follower

NewTailFollower creates a new Follower that handle file with tail library.

type LogFormatter

type LogFormatter func(str string) string

LogFormatter is a function used to format log string before output.

func NewLogFormatter

func NewLogFormatter(prefix string, color color.Color) LogFormatter

NewLogFormatter creates a function to make log prefix colored.

type Reader

type Reader interface {
	// Read reads the last `lines` lines from the file and returns a channel with raw strings.
	Read(ctx context.Context, lines int) (<-chan string, error)
}

Reader is an interface for reading the last `lines` lines from a file.

func NewTailReader

func NewTailReader(fileName string) Reader

NewTailReader creates a new Tailer that reads the last lines from the file with tail library.

Jump to

Keyboard shortcuts

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