Documentation
¶
Overview ¶
Package logger emits stage-level diagnostic messages from CTK in two interchangeable formats:
- text (default): human-friendly "[*] HH:MM:SS message" lines, identical to the legacy log.Logger output that the rest of the codebase already produces.
- json: one JSON object per line, suitable for SIEM ingestion. Every record carries any attributes attached via SetGlobalAttrs (run_id, scenario, account, region, ...) so detection engineers can correlate CTK validation actions with downstream telemetry.
The active format is selected by `common.log_format` in config.yaml and applied during runner.InitConfig.
Index ¶
- func Attrs(kv ...any) []slog.Attr
- func Error(v ...interface{})
- func Info(v ...interface{})
- func IsDebug() bool
- func SetDebug(enabled bool)
- func SetFormat(f Format)
- func SetGlobalAttrs(attrs ...slog.Attr)
- func SetOutput(w io.Writer)
- func SetOutputs(stdout, stderr io.Writer)
- func Warning(v ...interface{})
- type Format
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Attrs ¶ added in v0.2.7
Attrs converts alternating key / value pairs into a slog.Attr slice for SetGlobalAttrs convenience. Panics on odd argument count or non-string keys (matches slog's own contract).
func Error ¶
func Error(v ...interface{})
Error emits an error record. Always written to the stderr writer.
func Info ¶
func Info(v ...interface{})
Info emits a stage-level record. Suppressed when debug is off.
func IsDebug ¶ added in v0.2.7
func IsDebug() bool
IsDebug reports whether Info-level emission is currently enabled.
func SetDebug ¶ added in v0.2.0
func SetDebug(enabled bool)
SetDebug toggles whether Info-level records are emitted (legacy semantic).
func SetFormat ¶ added in v0.2.7
func SetFormat(f Format)
SetFormat switches the active output handler. Unknown values fall back to text and emit a warning so a typo in config.yaml degrades safely.
func SetGlobalAttrs ¶ added in v0.2.7
SetGlobalAttrs replaces the slice of attributes attached to every emitted record. The headless layer pins run_id / provider / account / region here so JSON output gets a stable correlation envelope and text output gets trailing `key=value` hints.
Pass no arguments to clear.
func SetOutput ¶ added in v0.2.0
SetOutput overrides both stdout and stderr to the same writer. Passing nil restores os.Stdout / os.Stderr (preserves legacy behavior).
func SetOutputs ¶ added in v0.2.0
SetOutputs separately overrides stdout and stderr. Either argument may be nil to fall back to OS defaults.