← All projects

darvaza.org/slog

Backend-agnostic structured logging interface with adapter handlers for popular Go loggers.

A backend-agnostic interface for structured logging. Libraries import slog to emit structured logs without forcing a specific backend on their users. Features method chaining (fluent API), six log levels, context integration, and immutable loggers safe for concurrent use.

Adapters§

Bidirectional adapters convert in both directions — use the external logger as an slog backend, or create an external logger backed by slog.

HandlerModuleDescription
logrBidirectional adapter for go-logr/logr
logrusBidirectional adapter for sirupsen/Logrus
zapBidirectional adapter for Uber's zap
zerologWraps rs/zerolog as an slog backend

Utility handlers§

HandlerModuleDescription
cblogChannel-based handler for custom log processing
filterMiddleware to filter and transform log entries
discardNo-op handler for optional logging
mockRecords log entries for testing assertions