logtail

package
v3.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package logtail keeps a bounded, in-memory ring of a process's recent log lines, with a live tap for followers. It is an io.Writer teed into the zerolog output, capturing each event's JSON without touching the real sink.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefault

func SetDefault(b *Buffer)

SetDefault installs the process-wide buffer.

Types

type Buffer

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

Buffer is a bounded, concurrency-safe ring of recent log lines with a live tap. The zero value is not usable; build one with New.

func Default

func Default() *Buffer

Default returns the process-wide buffer (a disabled one until SetDefault runs).

func New

func New(capacity int) *Buffer

New returns a Buffer holding up to capacity entries. A capacity <= 0 yields a disabled buffer (Write is a no-op).

func (*Buffer) Enabled

func (b *Buffer) Enabled() bool

Enabled reports whether the buffer retains anything (capacity > 0).

func (*Buffer) Read

func (b *Buffer) Read(f Filter) ([]Entry, bool)

Read returns the entries matching f, newest first. The bool reports whether more matched than were returned.

func (*Buffer) ReadAndSubscribe

func (b *Buffer) ReadAndSubscribe(f Filter) (backlog []Entry, live <-chan Entry, cancel func())

ReadAndSubscribe snapshots the matching backlog (oldest first) and registers a live subscriber under one lock, so no line is missed or duplicated in the gap. cancel must be called; it unsubscribes and closes live.

func (*Buffer) Write

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

Write records one serialized log event. zerolog may reuse the slice, so the bytes are copied. It never errors — logging must not fail on the tap.

type Entry

type Entry struct {
	Time    time.Time
	Level   string
	Service string
	Message string
	JSON    []byte
}

Entry is one buffered log line: the parsed, filterable fields plus the raw JSON.

type Filter

type Filter struct {
	Service  string
	MinLevel string
	Grep     string
	Since    time.Time
	Limit    int
}

Filter selects entries by service, minimum level, lower time bound and raw substring, capped at Limit (0 = default).

Jump to

Keyboard shortcuts

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