logbuffer

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package logbuffer provides an in-memory, fixed-capacity ring buffer of log lines that satisfies io.Writer, so it can be teed into zerolog alongside the real stdout output. The desktop (Wails) app plugs it into the global logger at startup and exposes the captured lines through the Settings "Logs" modal (view + save to a JSON file). Like the agent's metrics history, the buffer is intentionally not persisted — it is scoped to the process lifetime and lost on restart.

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 is a thread-safe ring buffer of the most recent log lines. Each call to Write stores one entry (zerolog emits exactly one complete JSON object, newline-terminated, per write); once max entries are held, the oldest are dropped. Logs are written from many goroutines (deploy, sync, tunnel workers), so — unlike the single-user metadata store — this genuinely needs its own lock.

func New

func New(max int) *Buffer

New returns a Buffer that retains at most max entries (a non-positive max falls back to a sane default).

func (*Buffer) Lines

func (b *Buffer) Lines() []string

Lines returns a snapshot copy of the captured entries, oldest first.

func (*Buffer) Write

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

Write records p as a single log entry (its trailing newline stripped) and always reports the whole slice as written, so it never trips zerolog's short-write handling.

Jump to

Keyboard shortcuts

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