logging

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.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 logging is how the library logs: through the logger its caller put in the context, and not at all when the caller put none.

The logger is a clog one. A program wires it the way clog has it,

ctx = clog.WithLogger(ctx, clog.New(handler))

and passes that context to an unpacker, which hands it on to its decomposers in their options. The library never logs to a global logger: what a program prints is the program's to decide.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context) *clog.Logger

FromContext returns the logger the caller wired into the context, and one that discards everything when there is none.

clog itself falls back to the program's default slog logger, which prints. That is right for a program and wrong for a library, whose warnings would turn up on the standard error of whatever uses it.

func Silent

func Silent() *clog.Logger

Silent returns a logger that discards everything, for code run with no context to read one from.

Types

type Failures

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

Failures collects the lookups a run skipped because they failed, to report them once.

A lookup that fails does not fail an extraction: the graph is built from what is at hand and the rest is left out. Left out in silence, though, the gap has nothing to explain it, so the caller is told. One message a lookup would bury everything else when a registry is down, which is when most of them fail at once.

The zero value is ready to use, and safe to add to from several goroutines.

func (*Failures) Add

func (f *Failures) Add(item string, err error)

Add records that the lookup of an item failed, and why. A nil error is for an item that came back with nothing and no reason given.

func (*Failures) Len

func (f *Failures) Len() int

Len returns how many lookups failed.

func (*Failures) Report

func (f *Failures) Report(log *clog.Logger, requested int, warning, detail string)

Report tells the logger of the failures, and nothing when there were none: a warning with how many failed of how many were requested and the first error, and the items themselves at the debug level.

func (*Failures) ReportQuietly

func (f *Failures) ReportQuietly(log *clog.Logger, requested int, summary, detail string)

ReportQuietly is Report with the summary at the debug level too, for failures the caller asked for: lookups that could not be made because networking was turned off.

Jump to

Keyboard shortcuts

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