golang-samber-slog

Designs Go logging pipelines with sampling, PII masking, and multi-sink routing.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/dashkan/pivox --skill golang-samber-slog-dashkan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-slog
Source: https://github.com/dashkan/pivox/tree/main/.agents/skills/golang-samber-slog
Command: npx skills add https://github.com/dashkan/pivox --skill golang-samber-slog-dashkan

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps Go teams design reliable structured logging pipelines so every log record is sampled, sanitized, routed, and delivered to the right backend with consistent slog.Handler behavior.

Core Features & Use Cases

  • Sampling-first noise reduction: apply slog-sampling as the outermost stage to drop low-value records early and avoid wasted CPU.
  • PII-safe attribute formatting: use slog-formatter middleware to transform attributes (for example, masking PII fields and formatting errors) before they reach sinks.
  • Multi-destination routing: compose handlers with slog-multi (Router, FirstMatch, Fanout, Pool, Failover, Pipe) to send the right events to the right systems (for example, route errors to Sentry and everything else to Loki).
  • HTTP request logging integration: add request-aware context through samber/slog HTTP middlewares (slog-gin, slog-chi, slog-fiber, slog-echo, slog-http) and optionally propagate fields via backend AttrFromContext.

Quick Start

Configure a Go slog logger using a sampling middleware (from slog-sampling) plus a PII formatter middleware (from slog-formatter) and route ERROR-level logs to Sentry while routing non-errors to Loki using slog-multi Router.

Frequently Asked Questions about golang-samber-slog

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a structured logging pipeline in Go that reduces noise and protects sensitive data?

Build a structured logging pipeline in Go by composing slog handlers with sampling middleware to drop low-value records early and formatter middleware to mask PII before logs reach sinks. This reduces CPU waste and ensures sensitive attributes are sanitized.

How do I route Go slog records to multiple logging backends like Sentry and Loki?

Route Go slog records to multiple backends by using a Router from slog-multi to send events to specific systems based on predicates, such as directing error-level logs to Sentry while sending non-errors to Loki for centralized storage.

Does the samber slog ecosystem support HTTP request logging with context enrichment?

Yes, the samber slog ecosystem supports HTTP request logging by integrating middlewares for frameworks like slog-gin, slog-chi, and slog-http to add request-aware context and propagate fields via AttrFromContext.

What is the correct handler ordering for Go slog pipelines using sampling and PII scrubbing?

The correct handler ordering for Go slog pipelines is sampling-first, applying slog-sampling as the outermost stage to drop records early, followed by slog-formatter middleware to transform attributes and mask PII before delivery.

Why should I use slog-multi for structured logging in high-throughput Go applications?

Use slog-multi for structured logging in high-throughput Go applications to reliably control throughput across handler compositions using Fanout, Pool, Failover, and Pipe functions for multi-destination routing and pipeline resilience.

Can I use Go slog middleware to format errors and mask IP addresses before logging?

Yes, you can use slog-formatter middleware to transform attributes in Go slog pipelines, allowing you to format errors and mask sensitive fields like IP addresses or PII before the records reach the final logging sinks.