logkit

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package logkit provides secret-safe subprocess logging helpers shared by Bomly components: argument and URL sanitizers, standard DEBUG command fields, and a counting stderr writer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandFields

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 SanitizeArgs

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

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

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