Documentation
¶
Index ¶
- Constants
- func CorrelationIDMiddleware(next http.Handler) http.Handler
- func Debug(ctx context.Context, msg string, keysAndValues ...any)
- func Error(ctx context.Context, err error, msg string, keysAndValues ...any)
- func Info(ctx context.Context, msg string, keysAndValues ...any)
- func InitializeLogger(debugLogging bool)
- func IsSensitiveKey(key string) bool
- func Log(ctx context.Context, level slog.Level, msg string, keysAndValues ...any)
- func LoggingMiddleware(next http.Handler, opts ...func(*LoggingOptions)) http.Handler
- func Warn(ctx context.Context, msg string, keysAndValues ...any)
- func WithCorrelationID(ctx context.Context, correlationID string) context.Context
- func WithDebugHealthChecks(enabled bool) func(*LoggingOptions)
- func WithLogger(ctx context.Context, logger *slog.Logger) context.Context
- func WithName(ctx context.Context, name string) context.Context
- func WithValues(ctx context.Context, keysAndValues ...any) context.Context
- type LoggingOptions
Constants ¶
View Source
const ( LevelDebug = slog.LevelDebug LevelInfo = slog.LevelInfo LevelWarn = slog.LevelWarn LevelError = slog.LevelError )
Alias slog levels for convenience.
View Source
const (
// CorrelationIDHeader is the HTTP header name for correlation IDs.
CorrelationIDHeader = "X-Correlation-ID"
)
Variables ¶
This section is empty.
Functions ¶
func CorrelationIDMiddleware ¶
CorrelationIDMiddleware adds correlation IDs to requests for tracing.
func InitializeLogger ¶
func InitializeLogger(debugLogging bool)
InitializeLogger sets up the global default logger.
func IsSensitiveKey ¶
IsSensitiveKey checks if a log key contains sensitive information.
func LoggingMiddleware ¶
func LoggingMiddleware(next http.Handler, opts ...func(*LoggingOptions)) http.Handler
LoggingMiddleware logs HTTP requests with structured logging.
func WithCorrelationID ¶
WithCorrelationID adds a correlation ID to the logging context.
func WithDebugHealthChecks ¶ added in v0.2.0
func WithDebugHealthChecks(enabled bool) func(*LoggingOptions)
WithDebugHealthChecks enables or disables debug logging for health check endpoints.
func WithLogger ¶
WithLogger adds a logger to the context.
Types ¶
type LoggingOptions ¶ added in v0.2.0
type LoggingOptions struct {
DebugHealthChecks bool
}
LoggingOptions holds configuration for the logging middleware.
Click to show internal directories.
Click to hide internal directories.