Documentation
¶
Overview ¶
Package logging provides structured deploy logging for StackKits CLI. It writes JSON-Lines log files to .stackkit/logs/ that capture every decision, phase timing, and error during generate/apply/remove operations.
Index ¶
- func FormatEntryHuman(w io.Writer, entry LogEntry)
- func IsValidRunID(value string) bool
- func LatestLogFile(logDir string) (string, error)
- func ListLogFiles(logDir string) ([]string, error)
- func MaskSecrets(attrs map[string]interface{}) map[string]interface{}
- func RedactText(value string) string
- func RedactValue(value interface{}) interface{}
- func ValidateCorrelationID(value string) error
- type DeployLogger
- type LogEntry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatEntryHuman ¶
FormatEntryHuman formats a log entry for human-readable display.
func IsValidRunID ¶
IsValidRunID accepts both the immutable legacy timestamp shape and the collision-resistant current shape used as an exact log basename.
func LatestLogFile ¶
LatestLogFile returns the path to the most recent log file.
func ListLogFiles ¶
ListLogFiles returns available log files sorted by name (newest last).
func MaskSecrets ¶
MaskSecrets replaces sensitive values recursively with "***" and redacts inline credential shapes from all retained string values.
func RedactText ¶
RedactText removes common inline credential shapes from untrusted text.
func RedactValue ¶
func RedactValue(value interface{}) interface{}
RedactValue recursively removes sensitive fields and inline secret strings.
func ValidateCorrelationID ¶
ValidateCorrelationID rejects implicit, path-like, or unbounded correlation values before they can influence evidence names or event identity.
Types ¶
type DeployLogger ¶
type DeployLogger struct {
// contains filtered or unexported fields
}
DeployLogger writes structured JSON-Lines logs for a single CLI run.
func New ¶
func New(logDir string) *DeployLogger
New creates a DeployLogger writing to one collision-resistant, exclusively created logDir/{run-id}.jsonl path. Returns nil (not an error) if the log directory cannot be created, so callers can always use deployLog.Event() without nil checks.
func NewWithCorrelation ¶
func NewWithCorrelation(logDir, correlationID string) (*DeployLogger, error)
NewWithCorrelation creates an exclusively owned log file and, when supplied, binds every event to one validated caller correlation ID.
func (*DeployLogger) Error ¶
func (dl *DeployLogger) Error(msg string, attrs ...slog.Attr)
Error logs an error event. Safe to call on nil receiver.
func (*DeployLogger) Event ¶
func (dl *DeployLogger) Event(msg string, attrs ...slog.Attr)
Event logs a structured event. Safe to call on nil receiver.
func (*DeployLogger) LogPath ¶
func (dl *DeployLogger) LogPath() string
LogPath returns the path to the log file.
func (*DeployLogger) RunID ¶
func (dl *DeployLogger) RunID() string
RunID returns the unique identifier for this log run.
type LogEntry ¶
type LogEntry struct {
Time string `json:"time"`
Level string `json:"level"`
Msg string `json:"msg"`
Fields map[string]interface{} `json:"-"`
RawJSON []byte `json:"-"`
}
LogEntry represents a single parsed log line for display/filtering.
func ParseLogLine ¶
ParseLogLine parses and defensively redacts one legacy or current JSONL event.
func ReadLogFile ¶
ReadLogFile parses a JSONL log file into entries.