logging

package
v0.42.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatEntryHuman

func FormatEntryHuman(w io.Writer, entry LogEntry)

FormatEntryHuman formats a log entry for human-readable display.

func IsValidRunID

func IsValidRunID(value string) bool

IsValidRunID accepts both the immutable legacy timestamp shape and the collision-resistant current shape used as an exact log basename.

func LatestLogFile

func LatestLogFile(logDir string) (string, error)

LatestLogFile returns the path to the most recent log file.

func ListLogFiles

func ListLogFiles(logDir string) ([]string, error)

ListLogFiles returns available log files sorted by name (newest last).

func MaskSecrets

func MaskSecrets(attrs map[string]interface{}) map[string]interface{}

MaskSecrets replaces sensitive values recursively with "***" and redacts inline credential shapes from all retained string values.

func RedactText

func RedactText(value string) string

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

func ValidateCorrelationID(value string) error

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) Close

func (dl *DeployLogger) Close()

Close flushes and closes the log file.

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.

func (*DeployLogger) Warn

func (dl *DeployLogger) Warn(msg string, attrs ...slog.Attr)

Warn logs a warning event. Safe to call on nil receiver.

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

func ParseLogLine(line []byte) (LogEntry, bool)

ParseLogLine parses and defensively redacts one legacy or current JSONL event.

func ReadLogFile

func ReadLogFile(path string) ([]LogEntry, error)

ReadLogFile parses a JSONL log file into entries.

Jump to

Keyboard shortcuts

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