debug

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package debug carries an opt-in, SDK-neutral debug switch through the request context. The root --debug flag (and the SUVE_DEBUG environment variable) turns it on; provider adapters read it to enable their cloud SDK's request/response logging, writing to the supplied writer (stderr in normal use).

Keeping this package free of any cloud SDK is deliberate: both the CLI layer (which sets the switch) and every provider adapter (which acts on it) can depend on it without violating the provider seam that confines each cloud SDK to its own provider package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func With

func With(ctx context.Context, cfg Config) context.Context

With returns a child context carrying cfg.

Types

type Config

type Config struct {
	// Enabled reports whether verbose debug logging was requested.
	Enabled bool
	// Writer is where debug output should go (typically stderr). Callers that
	// set Enabled must supply a non-nil Writer.
	Writer io.Writer
	// NoRedaction, when true, tells provider adapters to log full request and
	// response bodies and to stop masking sensitive headers, so the debug output
	// includes secret values and live credentials. It is opt-in via
	// --no-redaction and only meaningful when Enabled; the zero value keeps the
	// safe, redacted default.
	NoRedaction bool
}

Config describes the active debug settings pulled from a context.

func From

func From(ctx context.Context) Config

From returns the Config carried by ctx, or the zero value (disabled) when none is present.

func (Config) Logf

func (c Config) Logf(format string, args ...any)

Logf writes a single formatted debug line to the configured Writer, prefixed with "[suve debug <wall clock>] " so every provider's output shares one grep-able, time-correlatable format. It is a no-op when debug is disabled or no Writer is set, so callers can invoke it unconditionally. Centralizing the write here keeps provider adapters free of direct fmt.Fprint* usage (see the output package for the same rationale).

Callers supply the format WITHOUT a prefix or timestamp; multi-line payloads (e.g. HTTP dumps) are prefixed on their first line only.

Jump to

Keyboard shortcuts

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