luminyra

sl overview

Compose structured log handlers with failover, routing, formatting, sampling, and HTTP logging.

Use sl when a Go service needs to process structured logs in stages. Chain wraps a handler so you can redact sensitive values and format errors, sample by level or frequency, then send records to the configured destination.

Installation

You need Go 1.27 or later. Run the installation command in your Go module.

go get github.com/luminyra/sl

Routing, sampling, and requests

  • Failover tries the next handler after a failure. Router sends a record to the handler selected by a match condition.
  • FormatMiddleware can rewrite nested attributes. SampleMiddleware uses composable sampling rules to control log volume.
  • HTTPMiddleware logs HTTP requests and lets you configure request IDs, skip conditions, and levels by status code.

Go standard library integration

Use the standard-library slog.NewMultiHandler to broadcast a record to several handlers. sl adds failover, routing, formatting, sampling, and request logging in one dependency-free package.

Performance

When no attributes need rewriting, the original record is passed to the next handler without copying. HTTP middleware adds about 55 ns when the request log level is disabled.

The quickstart shows how to retain errors while cutting down on repeated retry messages.

References

On this page