logstream

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2025 License: ISC Imports: 6 Imported by: 0

Documentation

Overview

Package logstream implements an io.Writer that buffers lines written to it in a ring buffer and allows them to be streamed through an HTTP endpoint or retrieved as a snapshot.

This package is based on gokrazy's code, see https://github.com/gokrazy/gokrazy/blob/main/LICENSE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Streamer

type Streamer interface {
	io.Writer
	http.Handler

	// Lines returns all logged lines.
	Lines() []string

	// Stream generates a new channel which will stream any newly logged lines.
	// Deregister the stream by calling the returned function.
	Stream() (<-chan string, func())
}

Streamer is an io.Writer that contains all logged lines and allows to stream them.

func New

func New(size int) Streamer

New returns a new Streamer backed by a ring buffer of the given size.

Jump to

Keyboard shortcuts

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