logging

package
v0.20.2 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandFields added in v0.20.2

func CommandFields(executable string, args []string, workingDir string) []zap.Field

CommandFields returns the standard secret-safe DEBUG fields for a subprocess. Args are sanitized. The executable must be a resolved binary path or name, not a command string containing arguments or credentials.

func FormatDuration

func FormatDuration(value time.Duration) string

FormatDuration returns a short human-readable duration string for logs.

func NewConsole

func NewConsole(stderr io.Writer, verbosity int, quiet bool) *zap.Logger

NewConsole returns a logger configured for human-readable terminal output. verbosity controls the log level: 0 = warn, 1 = info, 2+ = debug. When quiet is true the logger only emits errors.

func SanitizeArgs added in v0.20.2

func SanitizeArgs(args []string) []string

SanitizeArgs returns a copy of args with credential values and URL user information removed. Non-secret arguments remain unchanged so DEBUG logs can still reproduce the command.

func SanitizeURL added in v0.20.2

func SanitizeURL(value string) string

SanitizeURL removes user information from a URL before it is logged. It fails closed when URL parsing fails. Query values are not inspected, so callers must not use this helper as a general query-string redactor.

Types

type CommandStderr

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

CommandStderr counts subprocess stderr and optionally mirrors it to the caller's debug output. It does not retain the contents.

func NewCommandStderr

func NewCommandStderr(visible io.Writer, debug bool) *CommandStderr

NewCommandStderr creates a subprocess stderr counter. When debug is true, writes are also forwarded to visible as they arrive.

func (*CommandStderr) ByteCount added in v0.20.2

func (w *CommandStderr) ByteCount() int64

ByteCount returns the number of bytes written to subprocess stderr.

func (*CommandStderr) Write

func (w *CommandStderr) Write(p []byte) (int, error)

Write records the byte count and mirrors the bytes when debug output is enabled.

Jump to

Keyboard shortcuts

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