Documentation
¶
Overview ¶
Package log provides secure telemetry logging with strict security controls.
SECURITY MODEL:
This package implements strict security controls for telemetry logging to prevent PII and sensitive information from being sent to external telemetry services.
REQUIREMENTS:
- Messages MUST be constant templates only - no dynamic parameter replacement
- Stack traces MUST be redacted to show only Datadog, runtime, and known 3rd party frames
- Errors MUST use SafeError type with message redaction
- slog.Any() only allowed with LogValuer implementations
BENEFITS:
- Constant messages enable deduplication to reduce redundant log transmission
SECURE USAGE PATTERNS:
// ✅ Correct - constant message with structured data
telemetrylog.Error("operation failed", slog.String("operation", "startup"))
telemetrylog.Error("validation error", slog.Any("error", SafeError(err)))
telemetrylog.Error("operation failed", slog.Any("error", SafeError(err)), WithStacktrace())
// ❌ Forbidden - dynamic messages
telemetrylog.Error(err.Error()) // Raw error message
telemetrylog.Error("failed: " + details) // String concatenation
telemetrylog.Error(fmt.Sprintf("error: %s", err)) // Format strings
// ❌ Forbidden - raw error exposure
telemetrylog.Error("failed", slog.Any("error", err)) // Raw error object
telemetrylog.Error("failed", slog.String("err", err.Error())) // Raw error message
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefaultLogger ¶ added in v2.4.0
func SetDefaultLogger(logger *Logger)
Types ¶
type SafeError ¶ added in v2.4.0
type SafeError struct {
// contains filtered or unexported fields
}
SafeError represents a sanitized error for secure telemetry logging. It only exposes the error type, never the error message, to prevent PII leakage.
func NewSafeError ¶ added in v2.4.0
NewSafeError creates a SafeError from a regular error
type SafeSlice ¶ added in v2.4.0
type SafeSlice struct {
// contains filtered or unexported fields
}
SafeSlice provides secure logging for slice/array types
func NewSafeSlice ¶ added in v2.4.0
NewSafeSlice creates a SafeSlice from any slice, converting items to strings
func NewSafeSliceWithLimit ¶ added in v2.4.0
NewSafeSliceWithLimit creates a SafeSlice with custom item limit