logbuf

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package logbuf keeps the most recent lines the app logged, in memory, with secrets taken out, so the Settings page can hand them to a person for a support request without a trip to the NAS log viewer.

Index

Constants

View Source
const Lines = 500

Lines is how many log lines Default keeps.

Variables

View Source
var Default = New(Lines)

Default is the buffer the app's log output is copied into.

Functions

func Scrub

func Scrub(line string) string

Scrub takes secrets out of one log line: passwords, API keys and tokens given as name=value, the query and login parts of URLs, authorization headers and long hexadecimal strings. It is deliberately greedy: a line that loses a harmless word is better than one that leaks a key.

Types

type Buffer

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

Buffer is a ring of the last n log lines. It is an io.Writer, so it can sit next to stderr in log.SetOutput. Every line is scrubbed of secrets as it comes in, so nothing sensitive is ever held here.

func New

func New(n int) *Buffer

New returns a buffer that keeps the last n lines.

func (*Buffer) Lines

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

Lines returns the kept lines, oldest first.

func (*Buffer) Write

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

Write splits p into lines and keeps them. It never fails.

type ScrubWriter

type ScrubWriter struct{ W io.Writer }

ScrubWriter passes what it is given on to W with secrets taken out (see Scrub). Wrap the process's stderr in it so what `docker logs` shows, which people paste into bug reports, is as clean as the in-memory copy. Each Write is taken to be whole log lines, which is how the log packages write.

func (ScrubWriter) Write

func (s ScrubWriter) Write(p []byte) (int, error)

Write scrubs p line by line and writes the result. It reports len(p) written when the underlying writer took the scrubbed text, whatever its length.

Jump to

Keyboard shortcuts

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