sloglinesbuffer

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: ISC Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

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

Buffer buffers slog Write() calls into a ring buffer, up to some number of max lines.

func (*Buffer) LastLogLines

func (buff *Buffer) LastLogLines(n int) []string

LastLogLines returns the last n log lines from the buffer.

func (*Buffer) Listen

func (buff *Buffer) Listen(cb func(s string)) *Listener

Listen to any Write() events by calling the specificed callback function. Note the callbacks are called synchronously with the Write() call, so care must be taken to not block for a significant amount of time.

The listener should be closed by calling its Close() method once it's no longer needed.

func (*Buffer) Write

func (buff *Buffer) Write(b []byte) (int, error)

type Listener

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

Listener holds a callback that is called every time a new log line is received.

func (*Listener) Close

func (l *Listener) Close()

Close stops this listener from receiving new callbacks.

Jump to

Keyboard shortcuts

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