logbuf

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logbuf captures the panel's own log output into an in-memory ring buffer and fans new lines out to live subscribers (the dashboard log viewer). It implements io.Writer so it can be installed as a tee on the standard logger — every log.Printf across the app is then both written to stderr (for journald) and made available to the panel UI.

Index

Constants

This section is empty.

Variables

View Source
var Default = New()

Default is the process-wide hub the standard logger tees into.

Functions

func Location added in v0.13.0

func Location() *time.Location

Location returns the log timezone, defaulting to server-local until one is set.

func SetLocation added in v0.13.0

func SetLocation(l *time.Location)

SetLocation sets the timezone used for log timestamps.

Types

type Hub

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

Hub keeps a ring of recent log lines and broadcasts new ones to subscribers.

func New

func New() *Hub

New builds an empty hub.

func (*Hub) Subscribe

func (h *Hub) Subscribe() (<-chan string, func())

Subscribe returns a channel of new log lines and an unsubscribe func.

func (*Hub) Tail

func (h *Hub) Tail() []string

Tail returns a copy of the buffered recent log lines.

func (*Hub) Write

func (h *Hub) Write(p []byte) (int, error)

Write implements io.Writer: it splits the written bytes into lines, appends them to the ring, and broadcasts each to live subscribers. It always reports the full length consumed so it composes cleanly inside an io.MultiWriter.

type RotatingFile

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

RotatingFile is a size-based rotating log writer (an io.Writer). When the active file would exceed MaxBytes, it is renamed to "<path>.1" (shifting any older backups up by one, dropping the oldest beyond MaxBackups) and a fresh file is opened. It is safe for concurrent writes.

func NewRotatingFile

func NewRotatingFile(path string, maxBytes int64, maxBackups int) (*RotatingFile, error)

NewRotatingFile opens (creating the directory if needed) a rotating log file at path, rolling over at maxBytes and keeping maxBackups rotated files.

func (*RotatingFile) Close

func (w *RotatingFile) Close() error

Close closes the underlying file.

func (*RotatingFile) Write

func (w *RotatingFile) Write(p []byte) (int, error)

Write appends p, rotating first if it would push the file past maxBytes.

Jump to

Keyboard shortcuts

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