Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaskValues ¶ added in v1.4.14
func MaskValues(vals ...string)
MaskValues registers secret values every later Begin and finish scrubs from the log. Safe for concurrent use; empty values are skipped.
Types ¶
type Entry ¶
type Entry struct {
Timestamp time.Time `json:"ts"`
Command string `json:"cmd"` // full argv joined, secrets redacted
User string `json:"user"` // os.Getenv("USER")
Duration float64 `json:"dur_s"`
ExitCode int `json:"exit"`
Error string `json:"error,omitempty"`
}
Entry represents a single command execution log record.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger appends JSON log lines to {logDir}/nself.log with rotation support.
func New ¶
New creates a Logger that writes to {logDir}/nself.log. The directory is created if it does not exist.
func (*Logger) Begin ¶
Begin records the command start. The returned function must be deferred by the caller; it computes duration and appends the log entry. If NSELF_CMD_LOG_ENABLED is "false" or "0", a no-op function is returned.
secrets are values the caller knows are secret (a positional or flag value); they join the MaskValues set and are scrubbed from the argv and the error.