log

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package log is the structured-logging entry point for Gantry.

The design docs mandate WARN-level emission in specific places (forced cache eviction in the design doc, HRW rank mismatch in the design doc). This package wraps log/slog with a consistent attribute vocabulary so those WARN lines are uniformly tagged and machine-parseable.

Standard attributes (use the helper constructors below to set them so keys don't drift):

subsystem one of {"mirror","transfer","cache","origin","coord",
 "discovery","hrw","members","cdsub","agent"}
digest OCI digest string ("sha256:...")
peer NodeID of a remote peer
registry upstream registry name
repo OCI repository
class the design doc failure class

Level conventions:

DEBUG per-RPC traces, per-byte transfer milestones
INFO state transitions, lifecycle events
WARN the design doc forced eviction, the design doc HRW rank mismatch, soft failures
 that the design explicitly calls out
ERROR hard failures requiring operator attention

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Class

func Class(c string) slog.Attr

Class builds a slog.Attr carrying the standard "class" key (the design doc failure class).

func Context

func Context(_ context.Context, parent *slog.Logger, attrs ...slog.Attr) *slog.Logger

Context is a tiny helper for the case where a function wants to bind per-request attributes onto a child logger and pass it down - e.g., a mirror request handler binding (registry, repo, digest) once at the top.

func Digest

func Digest(d fmt.Stringer) slog.Attr

Digest builds a slog.Attr carrying the standard "digest" key.

func Err

func Err(err error) slog.Attr

Err builds a slog.Attr carrying the standard "err" key.

func New

func New(w io.Writer, level, format string) *slog.Logger

New returns a *slog.Logger configured for the given level and format. format is "json" or "text"; anything else is treated as "json" with a warning logged at startup by the caller.

func NodeID

func NodeID(id fmt.Stringer) slog.Attr

NodeID builds a slog.Attr carrying the standard "node_id" key.

func Peer

func Peer(p fmt.Stringer) slog.Attr

Peer builds a slog.Attr carrying the standard "peer" key.

func Registry

func Registry(name string) slog.Attr

Registry builds a slog.Attr carrying the standard "registry" key.

func Repo

func Repo(name string) slog.Attr

Repo builds a slog.Attr carrying the standard "repo" key.

func Subsystem

func Subsystem(base *slog.Logger, name string) *slog.Logger

Subsystem returns a logger pre-tagged with subsystem=name. Use this once at subsystem construction time and pass the result around.

Types

This section is empty.

Jump to

Keyboard shortcuts

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