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 ¶
- type Cmd
- func (c Cmd) AppendLoggable(vl ...string) Cmd
- func (c Cmd) AppendLoggableKV(k, v string) Cmd
- func (c Cmd) AppendRedacted(vl ...string) Cmd
- func (c Cmd) AppendRedactedKV(k, v string) Cmd
- func (c Cmd) Argv() []string
- func (c Cmd) Combine(new Cmd) Cmd
- func (c Cmd) PlainText() string
- func (c Cmd) String() string
- func (c Cmd) StringSliceCMD() []string
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 ¶
NewLoggable initializes a safeCmd with the provided arguments, setting them all to safe to log.
func (Cmd) AppendLoggable ¶
AppendLoggable appends a series of values as tokens to the command, all of which will be considered safe to log.
func (Cmd) AppendLoggableKV ¶
AppendLoggableKV appends a key-value pair of tokens to the safeCmd, both of which are considered safe to log.
func (Cmd) AppendRedacted ¶
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 ¶
AppendRedactedKV appends a single key as safe to log, and its associated value as redacted.
func (Cmd) Combine ¶
Combine two safeCmd structures into one by appending the tokens from the second into the first.
func (Cmd) PlainText ¶
PlainText returns the entire command as a slice of string arguments. All arguments will be returned in plain text.
func (Cmd) String ¶
String returns a loggable version of the safeCmd, obfuscating any fields that are not marked as loggable in plain text
func (Cmd) StringSliceCMD ¶
StringSliceCMD is going to return the command c in the string slice format unlike PlainText