logsafe

package
v0.0.0-...-cc74a71 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package logsafe provides a framework for constructing commands that are safe for logging, where each token is considered unsafe and redacted, unless explicitly specified.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd []arg

Cmd is a way of building a command, token by token, such that it can be safely logged with redacted fields. The methods provided require the caller to explicitly specify whether a given token is safe to be logged or should be redacted.

func NewLoggable

func NewLoggable(args ...string) Cmd

NewLoggable initializes a safeCmd with the provided arguments, setting them all to safe to log.

func (Cmd) AppendLoggable

func (c Cmd) AppendLoggable(vl ...string) Cmd

AppendLoggable appends a series of values as tokens to the command, all of which will be considered safe to log.

func (Cmd) AppendLoggableKV

func (c Cmd) AppendLoggableKV(k, v string) Cmd

AppendLoggableKV appends a key-value pair of tokens to the safeCmd, both of which are considered safe to log.

func (Cmd) AppendRedacted

func (c Cmd) AppendRedacted(vl ...string) Cmd

AppendRedacted adds one or more tokens to the command, all of which will be considered secrets and therefore redacted when the Stringer is called.

func (Cmd) AppendRedactedKV

func (c Cmd) AppendRedactedKV(k, v string) Cmd

AppendRedactedKV appends a single key as safe to log, and its associated value as redacted.

func (Cmd) Argv

func (c Cmd) Argv() []string

Argv returns the argument vector

func (Cmd) Combine

func (c Cmd) Combine(new Cmd) Cmd

Combine two safeCmd structures into one by appending the tokens from the second into the first.

func (Cmd) PlainText

func (c Cmd) PlainText() string

PlainText returns the entire command as a slice of string arguments. All arguments will be returned in plain text.

func (Cmd) String

func (c Cmd) String() string

String returns a loggable version of the safeCmd, obfuscating any fields that are not marked as loggable in plain text

func (Cmd) StringSliceCMD

func (c Cmd) StringSliceCMD() []string

StringSliceCMD is going to return the command c in the string slice format unlike PlainText

Jump to

Keyboard shortcuts

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