Help us shape the future of Go! Take the 2026 Go Developer Survey

faillog

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package faillog logs a repeating background failure (a heartbeat or sync loop that cannot reach the database) without flooding the log: the first failure is logged at WARN, later ones are summarised at most once per interval, and the recovery is logged once at INFO.

Index

Constants

View Source
const DefaultEvery = time.Minute

DefaultEvery is how often a continuing failure is summarised.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tracker

type Tracker struct {

	// Every is the summary interval (DefaultEvery); Now the clock. Both
	// may be changed before first use (tests).
	Every time.Duration
	Now   func() time.Time
	// contains filtered or unexported fields
}

Tracker follows one repeating operation. The zero value is not usable; call New. Methods are safe for concurrent use and a nil *Tracker ignores every call.

func New

func New(log *slog.Logger, what string) *Tracker

New tracks the operation described by what ("cluster: heartbeat").

func (*Tracker) Fail

func (t *Tracker) Fail(err error, attrs ...any)

Fail records a failed attempt: the first of an outage is logged at WARN, later ones are summarised at most once per Every.

func (*Tracker) Failing

func (t *Tracker) Failing() (bool, time.Time)

Failing reports whether the operation is currently failing, and since when.

func (*Tracker) OK

func (t *Tracker) OK()

OK records a successful attempt; after a failure it logs the recovery once at INFO.

Jump to

Keyboard shortcuts

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