debug

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close() error

func Open

func Open(w Writer) error

The error is a warning, not an error. It indicates possible data loss.

func OpenFile

func OpenFile(filename string) error

func Write

func Write(source string, data string)

source should be unique for every call site.

func WriteBytes

func WriteBytes(source string, data []byte)

source should be unique for every call site.

func Writef

func Writef(source string, format string, args ...any)

source should be unique for every call site.

Types

type Debug

type Debug interface {
	WriteBytes(data []byte)
	Write(data string)
	Writef(format string, args ...any)
}

type DebugKind

type DebugKind uint16
const (
	DebugKindInvalid DebugKind = iota
	DebugKindBytes
	DebugKindString
)

type Reader

type Reader interface {
	// Return a list of all sources in the order they were written.
	Sources() []string

	// Return the earliest and latest timestamps in the log.
	TimeRange() (time.Time, time.Time)

	Sample(fn func(ts time.Time, kind DebugKind, source string, data []byte) error) error

	// Guaranteed to iterate over all entries in the order they were written.
	Each(fn func(ts time.Time, kind DebugKind, source string, data []byte) error) error

	// Guaranteed to iterate over all entries for a given source in the order they were written.
	EachSource(source string, fn func(ts time.Time, kind DebugKind, data []byte) error) error

	// Guaranteed to iterate over all entries that match the search criteria in the order they were written.
	Search(opts SearchOptions, fn func(ts time.Time, kind DebugKind, source string, data []byte) error) error

	// Return the number of entries that match the search criteria.
	Count(opts SearchOptions) (int, error)
}

func NewReader

func NewReader(r io.ReaderAt, indexReader io.ReadSeeker) (Reader, error)

func NewReaderFromFile

func NewReaderFromFile(filename string) (Reader, io.Closer, error)

type SearchOptions

type SearchOptions struct {
	// The start and end timestamps to search within.
	Start time.Time
	End   time.Time

	// LimitStart only returns the first N entries after the start timestamp.
	// If both LimitStart and LimitEnd are set then an error is returned.
	LimitStart int64

	// LimitEnd only returns the last N entries before the end timestamp.
	// If both LimitStart and LimitEnd are set then an error is returned.
	LimitEnd int64

	// Only return entries for the given sources.
	Sources []string
}

type Writer

type Writer interface {
	io.WriterAt
	io.Closer
}

type WriterTo

type WriterTo interface {
	WriteTo(w io.WriterAt) (n int64, err error)
}

func OpenMemory

func OpenMemory() (WriterTo, error)

Jump to

Keyboard shortcuts

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