log

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package log provides structured logging for gitcontribute using log/slog. Each package receives a pre-configured *slog.Logger at construction time. Logs are written to stderr; stdout is reserved for CLI program output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(component string) *slog.Logger

New creates a structured logger for the given component name. The component name is attached to every log line as an attribute. In production (non-tty), output is JSON. In development (tty), a human-readable text handler is used.

func TraceFromContext

func TraceFromContext(ctx context.Context) string

TraceFromContext extracts a trace ID from the context for logging.

func WithTrace

func WithTrace(ctx context.Context, traceID string) context.Context

WithTrace adds a trace ID to the context for correlation across log lines. Use log/slog's built-in context propagation via *Context methods.

Types

type RedactedString

type RedactedString string

RedactedString wraps a potentially sensitive string so that it is redacted when logged. The LogValue method ensures only a safe prefix is emitted.

func (RedactedString) LogValue

func (s RedactedString) LogValue() slog.Value

LogValue implements slog.LogValuer to emit a redacted representation.

Jump to

Keyboard shortcuts

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