logring

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package logring keeps the last lines a child process wrote.

Both the function runner and the Cloud Run runner need it: a child's output is the only account of why it failed, and it has to be bounded or a chatty process grows the emulator without end.

Index

Constants

View Source
const DefaultLines = 1000

DefaultLines is how much of a child's output is kept. Enough to explain a crash or read a request trace, small enough that a chatty function cannot grow the emulator without bound.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ring

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

Ring keeps the last lines a function wrote and fans new ones out to followers. It is the function's stdout and stderr merged, in the order the child produced them.

func New

func New(max int) *Ring

func (*Ring) Follow

func (l *Ring) Follow() (<-chan string, func())

Follow returns a channel of lines written from now on, and a function to stop following. The channel is buffered; a follower that stops reading drops lines rather than blocking the function.

func (*Ring) Snapshot

func (l *Ring) Snapshot() []string

Snapshot returns the lines held right now.

func (*Ring) Tail

func (l *Ring) Tail(n int) string

Tail returns the last n lines as text, for attaching to an error.

func (*Ring) Write

func (l *Ring) Write(p []byte) (int, error)

Write accepts arbitrary chunks and splits them into lines, holding an incomplete trailing line until its newline arrives.

Jump to

Keyboard shortcuts

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