Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigLevelStringToSlogLevel(level string) slog.Level
- func DisableErrorMirroring()
- func EnableErrorMirroring()
- func HTTPLogContextAttrs(ctx context.Context) []slog.Attr
- func NewDualHandler(primary slog.Handler, secondary slog.Handler) slog.Handler
- func NewFriendlyErrorHandler(w io.Writer) slog.Handler
- func WithHTTPLogContext(ctx context.Context, update HTTPLogContext) context.Context
- type HTTPLogContext
- type Key
Constants ¶
const LevelTrace = slog.LevelDebug - 4
LevelTrace is a custom trace level for slog Using LevelDebug - 4 which equals -8
Variables ¶
var HTTPLogContextKey = httpLogContextKey{}
var LoggerKey = Key{}
Functions ¶
func DisableErrorMirroring ¶ added in v0.2.0
func DisableErrorMirroring()
DisableErrorMirroring stops mirroring error level logs to the secondary handler. This is used for interactive commands where stderr output would disrupt the UI.
func EnableErrorMirroring ¶ added in v0.2.0
func EnableErrorMirroring()
EnableErrorMirroring ensures error level logs are mirrored to the secondary handler when one is configured.
func HTTPLogContextAttrs ¶ added in v0.5.0
HTTPLogContextAttrs converts context metadata to slog attributes.
func NewDualHandler ¶ added in v0.2.0
NewDualHandler wraps a primary slog.Handler and, optionally, a secondary handler that only receives error level records when mirroring is enabled.
func NewFriendlyErrorHandler ¶ added in v0.3.2
NewFriendlyErrorHandler returns a slog.Handler that renders error records in a concise, human-friendly format suitable for console output.
func WithHTTPLogContext ¶ added in v0.5.0
func WithHTTPLogContext(ctx context.Context, update HTTPLogContext) context.Context
WithHTTPLogContext merges non-empty fields from update into ctx.
Types ¶
type HTTPLogContext ¶ added in v0.5.0
type HTTPLogContext struct {
CommandPath string
CommandVerb string
CommandMode string
CommandProduct string
Workflow string
WorkflowPhase string
WorkflowComponent string
WorkflowMode string
WorkflowNamespace string
WorkflowAction string
WorkflowChangeID string
WorkflowResource string
WorkflowRef string
SDKOperationID string
}
HTTPLogContext contains contextual metadata emitted with SDK HTTP logs.
func HTTPLogContextFromContext ¶ added in v0.5.0
func HTTPLogContextFromContext(ctx context.Context) HTTPLogContext
HTTPLogContextFromContext extracts HTTP logging metadata from ctx.