[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CFMKZ6PZHV751G2W2NWABS":3,"skill-same:01M6CFMKZ6PZHV751G2W2NWABS":133},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":26,"publishedAt":47,"linkOnly":48,"markdownContent":49,"markdownBody":50,"frontMatter":51,"refName":91,"commitSha":92,"skillDirectory":93,"forksCount":94,"repositoryHtmlUrl":95,"repositoryHomepageUrl":6,"ownerHtmlUrl":96,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":97,"install":98,"resources":110},"01M6CFMKZ6PZHV751G2W2NWABS","golang-samber-slog",null,"Structured logging extensions for Golang using samber\u002Fslog-**** packages — multi-handler pipelines (slog-multi), log sampling (slog-sampling), attribute formatting (slog-formatter), HTTP middleware (slog-fiber, slog-gin, slog-chi, slog-echo), and backend routing (slog-datadog, slog-sentry, slog-loki, slog-syslog, slog-logstash, slog-graylog...). Apply when using or adopting slog, or when the codebase already imports any github.com\u002Fsamber\u002Fslog-* package.","rockcookies\u002Fskills","rockcookies","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F3498265?v=4","01M6CF9C16X3SDSKZX6ANH7HQM","Jacob He","01M6CF9C53JP821FCW6R9B00AJ",1,"MIT","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-samber-slog\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],"golang samber slog","golang","package","Echo","log","sampling","projects","gopls","Bash","syslog","datadog","MCP","sentry","harness","code","routing","lint","packages","http","codex","2026-11-10 10:12:30",false,"---\nname: golang-samber-slog\ndescription: >-\n  Structured logging extensions for Golang using samber\u002Fslog-**** packages —\n  multi-handler pipelines (slog-multi), log sampling (slog-sampling), attribute\n  formatting (slog-formatter), HTTP middleware (slog-fiber, slog-gin, slog-chi,\n  slog-echo), and backend routing (slog-datadog, slog-sentry, slog-loki,\n  slog-syslog, slog-logstash, slog-graylog...). Apply when using or adopting\n  slog, or when the codebase already imports any github.com\u002Fsamber\u002Fslog-*\n  package.\nuser-invocable: true\nlicense: MIT\ncompatibility: >-\n  Designed for Claude Code, Codex or similar harness, and for projects using\n  Golang.\nmetadata:\n  author: samber\n  version: 1.1.0\n  openclaw:\n    emoji: ?\n    homepage: https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang\n    requires:\n      bins:\n        - go\n    install: []\n    skill-library-version:\n      slog-multi: 1.8.0\n      slog-sampling: 1.6.0\n      slog-formatter: 1.3.0\n      slog-fiber: 1.22.1\n      slog-gin: 1.21.0\n      slog-chi: 1.19.0\n      slog-echo: 1.21.0\n      slog-http: 1.12.0\n      slog-betterstack: 1.4.4\n      slog-channel: 1.4.4\n      slog-datadog: 2.10.4\n      slog-sentry: 2.10.3\n      slog-loki: 3.7.2\n      slog-syslog: 2.5.4\n      slog-logstash: 2.6.4\n      slog-graylog: 2.7.5\n      slog-fluentd: 2.5.4\n      slog-kafka: 2.6.5\n      slog-logrus: 2.5.4\n      slog-zap: 2.6.4\n      slog-zerolog: 2.9.2\n      slog-slack: 2.7.5\n      slog-telegram: 2.4.4\n      slog-webhook: 2.8.4\n      slog-mattermost: 2.5.4\n      slog-microsoft-teams: 2.7.4\n      slog-nats: 0.4.5\n      slog-otel: 0.1.0\n      slog-parquet: 2.5.2\n      slog-quickwit: 0.3.4\n      slog-rollbar: 2.7.4\n      slog-mock: 0.1.0\nallowed-tools: >-\n  Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent\n  WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs\n  AskUserQuestion Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*\npaths:\n  - '**\u002F*.go'\n---\n\n**Persona:** You are a Go logging architect. You design log pipelines where every record flows through the right handlers — sampling drops noise early, formatters strip PII before records leave the process, and routers send errors to Sentry while info goes to Loki.\n\n# samber\u002Fslog-\\*\\*\\*\\* — Structured Logging Pipeline for Go\n\n20+ composable `slog.Handler` packages for Go 1.21+. Three core pipeline libraries plus HTTP middlewares and backend sinks that all implement the standard `slog.Handler` interface.\n\n**Official resources:**\n\n- [github.com\u002Fsamber\u002Fslog-multi](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-multi) — handler composition\n- [github.com\u002Fsamber\u002Fslog-sampling](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-sampling) — throughput control\n- [github.com\u002Fsamber\u002Fslog-formatter](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-formatter) — attribute transformation\n\nThis skill is not exhaustive. Please refer to library documentation and code examples for more information. For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `golang-pkg-go-dev` skill (`godig`) — prefer it over Context7 for Go package facts. To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `golang-gopls` skill (`gopls`). Context7 remains a fallback for docs not indexed on pkg.go.dev.\n\n## The Pipeline Model\n\nEvery samber\u002Fslog pipeline follows a canonical ordering. Records flow left to right — place sampling first to drop early and avoid wasting CPU on records that never reach a sink.\n\n```\nrecord → [Sampling] → [Pipe: trace\u002FPII] → [Router] → [Sinks]\n```\n\nOrder matters: sampling before formatting saves CPU. Formatting before routing ensures all sinks receive clean attributes. Reversing this wastes work on records that get dropped.\n\n## Core Libraries\n\n| Library | Purpose | Key constructors |\n| --- | --- | --- |\n| `slog-multi` | Handler composition | `Fanout`, `Router`, `FirstMatch`, `Failover`, `Pool`, `Pipe` |\n| `slog-sampling` | Throughput control | `UniformSamplingOption`, `ThresholdSamplingOption`, `AbsoluteSamplingOption`, `CustomSamplingOption` |\n| `slog-formatter` | Attribute transforms | `PIIFormatter`, `ErrorFormatter`, `FormatByType[T]`, `FormatByKey`, `FlattenFormatterMiddleware` |\n\n## slog-multi — Handler Composition\n\nSix composition patterns, each for a different routing need:\n\n| Pattern | Behavior | Latency impact |\n| --- | --- | --- |\n| `Fanout(handlers...)` | Broadcast to all handlers sequentially | Sum of all handler latencies |\n| `Router().Add(h, predicate).Handler()` | Route to ALL matching handlers | Sum of matching handlers |\n| `Router().Add(...).FirstMatch().Handler()` | Route to FIRST match only | Single handler latency |\n| `Failover()(handlers...)` | Try sequentially until one succeeds | Primary handler latency (happy path) |\n| `Pool()(handlers...)` | Load-balance: sends each record to ONE handler | Single handler latency |\n| `Pipe(middlewares...).Handler(sink)` | Middleware chain before sink | Middleware overhead + sink |\n\n```go\n\u002F\u002F Route errors to Sentry, all logs to stdout\nlogger := slog.New(\n    slogmulti.Router().\n        Add(sentryHandler, slogmulti.LevelIs(slog.LevelError)).\n        Add(slog.NewJSONHandler(os.Stdout, nil)).\n        Handler(),\n)\n```\n\nBuilt-in predicates: `LevelIs`, `LevelIsNot`, `MessageIs`, `MessageIsNot`, `MessageContains`, `MessageNotContains`, `AttrValueIs`, `AttrKindIs`.\n\nFor full code examples of every pattern, see [Pipeline Patterns](references\u002Fpipeline-patterns.md).\n\n## slog-sampling — Throughput Control\n\n| Strategy | Behavior | Best for |\n| --- | --- | --- |\n| Uniform | Drop fixed % of all records | Dev\u002Fstaging noise reduction |\n| Threshold | Log first N per interval, then sample at rate R | Production — preserves initial visibility |\n| Absolute | Cap at N records per interval globally | Hard cost control |\n| Custom | User function returns sample rate per record | Level-aware or time-aware rules |\n\nSampling MUST be the outermost handler in the pipeline — placing it after formatting wastes CPU on records that get dropped.\n\n```go\n\u002F\u002F Threshold: log first 10 per 5s, then 10% — errors always pass through via Router\nlogger := slog.New(\n    slogmulti.\n        Pipe(slogsampling.ThresholdSamplingOption{\n            Tick: 5 * time.Second, Threshold: 10, Rate: 0.1,\n        }.NewMiddleware()).\n        Handler(innerHandler),\n)\n```\n\nMatchers group similar records for deduplication: `MatchByLevel()`, `MatchByMessage()`, `MatchByLevelAndMessage()` (default), `MatchBySource()`, `MatchByAttribute(groups, key)`.\n\nFor strategy comparison and configuration details, see [Sampling Strategies](references\u002Fsampling-strategies.md).\n\n## slog-formatter — Attribute Transformation\n\nApply as a `Pipe` middleware so all downstream handlers receive clean attributes.\n\n```go\nlogger := slog.New(\n    slogmulti.Pipe(slogformatter.NewFormatterMiddleware(\n        slogformatter.PIIFormatter(\"user\"),          \u002F\u002F mask PII fields\n        slogformatter.ErrorFormatter(\"error\"),       \u002F\u002F structured error info\n        slogformatter.IPAddressFormatter(\"client\"),  \u002F\u002F mask IP addresses\n    )).Handler(slog.NewJSONHandler(os.Stdout, nil)),\n)\n```\n\nKey formatters: `PIIFormatter`, `ErrorFormatter`, `TimeFormatter`, `UnixTimestampFormatter`, `IPAddressFormatter`, `HTTPRequestFormatter`, `HTTPResponseFormatter`. Generic formatters: `FormatByType[T]`, `FormatByKey`, `FormatByKind`, `FormatByGroup`, `FormatByGroupKey`. Flatten nested attributes with `FlattenFormatterMiddleware`.\n\n## HTTP Middlewares\n\nConsistent pattern across frameworks: `router.Use(slogXXX.New(logger))`.\n\nAvailable: `slog-gin`, `slog-echo`, `slog-fiber`, `slog-chi`, `slog-http` (net\u002Fhttp).\n\nAll share a `Config` struct with: `DefaultLevel`, `ClientErrorLevel`, `ServerErrorLevel`, `WithRequestBody`, `WithResponseBody`, `WithUserAgent`, `WithRequestID`, `WithTraceID`, `WithSpanID`, `Filters`.\n\n```go\n\u002F\u002F Gin with filters — skip health checks\nrouter.Use(sloggin.NewWithConfig(logger, sloggin.Config{\n    DefaultLevel:     slog.LevelInfo,\n    ClientErrorLevel: slog.LevelWarn,\n    ServerErrorLevel: slog.LevelError,\n    WithRequestBody:  true,\n    Filters: []sloggin.Filter{\n        sloggin.IgnorePath(\"\u002Fhealth\", \"\u002Fmetrics\"),\n    },\n}))\n```\n\nFor framework-specific setup, see [HTTP Middlewares](references\u002Fhttp-middlewares.md).\n\n## Backend Sinks\n\nAll follow the `Option{}.NewXxxHandler()` constructor pattern.\n\n| Category     | Packages                                                   |\n| ------------ | ---------------------------------------------------------- |\n| Cloud        | `slog-datadog`, `slog-sentry`, `slog-loki`, `slog-graylog` |\n| Messaging    | `slog-kafka`, `slog-fluentd`, `slog-logstash`, `slog-nats` |\n| Notification | `slog-slack`, `slog-telegram`, `slog-webhook`              |\n| Storage      | `slog-parquet`                                             |\n| Bridges      | `slog-zap`, `slog-zerolog`, `slog-logrus`                  |\n\n**Batch handlers require graceful shutdown** — `slog-datadog`, `slog-loki`, `slog-kafka`, and `slog-parquet` buffer records internally. Flush on shutdown (e.g., `handler.Stop(ctx)` for Datadog, `lokiClient.Stop()` for Loki, `writer.Close()` for Kafka) or buffered logs are lost.\n\nFor configuration examples and shutdown patterns, see [Backend Handlers](references\u002Fbackend-handlers.md).\n\n## Common Mistakes\n\n| Mistake | Why it fails | Fix |\n| --- | --- | --- |\n| Sampling after formatting | Wastes CPU formatting records that get dropped | Place sampling as outermost handler |\n| Fanout to many synchronous handlers | Blocks caller — latency is sum of all handlers | Use `Pool()` for concurrent dispatch |\n| Missing shutdown flush on batch handlers | Buffered logs lost on shutdown | `defer handler.Stop(ctx)` (Datadog), `defer lokiClient.Stop()` (Loki), `defer writer.Close()` (Kafka) |\n| Router without default\u002Fcatch-all handler | Unmatched records silently dropped | Add a handler with no predicate as catch-all |\n| `AttrFromContext` without HTTP middleware | Context has no request attributes to extract | Install `slog-gin`\u002F`echo`\u002F`fiber`\u002F`chi` middleware first |\n| Using `Pipe` with no middleware | No-op wrapper adding per-record overhead | Remove `Pipe()` if no middleware needed |\n\n## Performance Warnings\n\n- **Fanout latency** = sum of all handler latencies (sequential). With 5 handlers at 10ms each, every log call costs 50ms. Use `Pool()` to reduce to max(latencies)\n- **Pipe middleware** adds per-record function call overhead — keep chains short (2-4 middlewares)\n- **slog-formatter** processes attributes sequentially — many formatters compound. For hot-path attribute formatting, prefer implementing `slog.LogValuer` on your types instead\n- **Benchmark** your pipeline with `go test -bench` before production deployment\n\n**Diagnose:** measure per-record allocation and latency of your pipeline and identify which handler in the chain allocates most.\n\n## Best Practices\n\n1. **Sample first, format second, route last** — this canonical ordering minimizes wasted work and ensures all sinks see clean data\n2. **Use Pipe for cross-cutting concerns** — trace ID injection and PII scrubbing belong in middleware, not per-handler logic\n3. **Test pipelines with `slogmulti.NewHandleInlineHandler`** — assert on records reaching each stage without real sinks\n4. **Use `AttrFromContext`** to propagate request-scoped attributes from HTTP middleware to all handlers\n5. **Prefer Router over Fanout** when handlers need different record subsets — Router evaluates predicates and skips non-matching handlers\n\n## Cross-References\n\n- → See `golang-observability` skill for slog fundamentals (levels, context, handler setup, migration)\n- → See `golang-error-handling` skill for the log-or-return rule\n- → See `golang-security` skill for PII handling in logs\n- → See `golang-samber-oops` skill for structured error context with `samber\u002Foops`\n\nIf you encounter a bug or unexpected behavior in any samber\u002Fslog-\\* package, open an issue at the relevant repository (e.g., [slog-multi\u002Fissues](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-multi\u002Fissues), [slog-sampling\u002Fissues](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-sampling\u002Fissues)).\n","**Persona:** You are a Go logging architect. You design log pipelines where every record flows through the right handlers — sampling drops noise early, formatters strip PII before records leave the process, and routers send errors to Sentry while info goes to Loki.\n\n# samber\u002Fslog-\\*\\*\\*\\* — Structured Logging Pipeline for Go\n\n20+ composable `slog.Handler` packages for Go 1.21+. Three core pipeline libraries plus HTTP middlewares and backend sinks that all implement the standard `slog.Handler` interface.\n\n**Official resources:**\n\n- [github.com\u002Fsamber\u002Fslog-multi](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-multi) — handler composition\n- [github.com\u002Fsamber\u002Fslog-sampling](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-sampling) — throughput control\n- [github.com\u002Fsamber\u002Fslog-formatter](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-formatter) — attribute transformation\n\nThis skill is not exhaustive. Please refer to library documentation and code examples for more information. For Go package docs, symbols, versions, importers, and known vulnerabilities, → See `golang-pkg-go-dev` skill (`godig`) — prefer it over Context7 for Go package facts. To navigate this library's usage in your own code (definitions, call sites, diagnostics), → See `golang-gopls` skill (`gopls`). Context7 remains a fallback for docs not indexed on pkg.go.dev.\n\n## The Pipeline Model\n\nEvery samber\u002Fslog pipeline follows a canonical ordering. Records flow left to right — place sampling first to drop early and avoid wasting CPU on records that never reach a sink.\n\n```\nrecord → [Sampling] → [Pipe: trace\u002FPII] → [Router] → [Sinks]\n```\n\nOrder matters: sampling before formatting saves CPU. Formatting before routing ensures all sinks receive clean attributes. Reversing this wastes work on records that get dropped.\n\n## Core Libraries\n\n| Library | Purpose | Key constructors |\n| --- | --- | --- |\n| `slog-multi` | Handler composition | `Fanout`, `Router`, `FirstMatch`, `Failover`, `Pool`, `Pipe` |\n| `slog-sampling` | Throughput control | `UniformSamplingOption`, `ThresholdSamplingOption`, `AbsoluteSamplingOption`, `CustomSamplingOption` |\n| `slog-formatter` | Attribute transforms | `PIIFormatter`, `ErrorFormatter`, `FormatByType[T]`, `FormatByKey`, `FlattenFormatterMiddleware` |\n\n## slog-multi — Handler Composition\n\nSix composition patterns, each for a different routing need:\n\n| Pattern | Behavior | Latency impact |\n| --- | --- | --- |\n| `Fanout(handlers...)` | Broadcast to all handlers sequentially | Sum of all handler latencies |\n| `Router().Add(h, predicate).Handler()` | Route to ALL matching handlers | Sum of matching handlers |\n| `Router().Add(...).FirstMatch().Handler()` | Route to FIRST match only | Single handler latency |\n| `Failover()(handlers...)` | Try sequentially until one succeeds | Primary handler latency (happy path) |\n| `Pool()(handlers...)` | Load-balance: sends each record to ONE handler | Single handler latency |\n| `Pipe(middlewares...).Handler(sink)` | Middleware chain before sink | Middleware overhead + sink |\n\n```go\n\u002F\u002F Route errors to Sentry, all logs to stdout\nlogger := slog.New(\n    slogmulti.Router().\n        Add(sentryHandler, slogmulti.LevelIs(slog.LevelError)).\n        Add(slog.NewJSONHandler(os.Stdout, nil)).\n        Handler(),\n)\n```\n\nBuilt-in predicates: `LevelIs`, `LevelIsNot`, `MessageIs`, `MessageIsNot`, `MessageContains`, `MessageNotContains`, `AttrValueIs`, `AttrKindIs`.\n\nFor full code examples of every pattern, see [Pipeline Patterns](references\u002Fpipeline-patterns.md).\n\n## slog-sampling — Throughput Control\n\n| Strategy | Behavior | Best for |\n| --- | --- | --- |\n| Uniform | Drop fixed % of all records | Dev\u002Fstaging noise reduction |\n| Threshold | Log first N per interval, then sample at rate R | Production — preserves initial visibility |\n| Absolute | Cap at N records per interval globally | Hard cost control |\n| Custom | User function returns sample rate per record | Level-aware or time-aware rules |\n\nSampling MUST be the outermost handler in the pipeline — placing it after formatting wastes CPU on records that get dropped.\n\n```go\n\u002F\u002F Threshold: log first 10 per 5s, then 10% — errors always pass through via Router\nlogger := slog.New(\n    slogmulti.\n        Pipe(slogsampling.ThresholdSamplingOption{\n            Tick: 5 * time.Second, Threshold: 10, Rate: 0.1,\n        }.NewMiddleware()).\n        Handler(innerHandler),\n)\n```\n\nMatchers group similar records for deduplication: `MatchByLevel()`, `MatchByMessage()`, `MatchByLevelAndMessage()` (default), `MatchBySource()`, `MatchByAttribute(groups, key)`.\n\nFor strategy comparison and configuration details, see [Sampling Strategies](references\u002Fsampling-strategies.md).\n\n## slog-formatter — Attribute Transformation\n\nApply as a `Pipe` middleware so all downstream handlers receive clean attributes.\n\n```go\nlogger := slog.New(\n    slogmulti.Pipe(slogformatter.NewFormatterMiddleware(\n        slogformatter.PIIFormatter(\"user\"),          \u002F\u002F mask PII fields\n        slogformatter.ErrorFormatter(\"error\"),       \u002F\u002F structured error info\n        slogformatter.IPAddressFormatter(\"client\"),  \u002F\u002F mask IP addresses\n    )).Handler(slog.NewJSONHandler(os.Stdout, nil)),\n)\n```\n\nKey formatters: `PIIFormatter`, `ErrorFormatter`, `TimeFormatter`, `UnixTimestampFormatter`, `IPAddressFormatter`, `HTTPRequestFormatter`, `HTTPResponseFormatter`. Generic formatters: `FormatByType[T]`, `FormatByKey`, `FormatByKind`, `FormatByGroup`, `FormatByGroupKey`. Flatten nested attributes with `FlattenFormatterMiddleware`.\n\n## HTTP Middlewares\n\nConsistent pattern across frameworks: `router.Use(slogXXX.New(logger))`.\n\nAvailable: `slog-gin`, `slog-echo`, `slog-fiber`, `slog-chi`, `slog-http` (net\u002Fhttp).\n\nAll share a `Config` struct with: `DefaultLevel`, `ClientErrorLevel`, `ServerErrorLevel`, `WithRequestBody`, `WithResponseBody`, `WithUserAgent`, `WithRequestID`, `WithTraceID`, `WithSpanID`, `Filters`.\n\n```go\n\u002F\u002F Gin with filters — skip health checks\nrouter.Use(sloggin.NewWithConfig(logger, sloggin.Config{\n    DefaultLevel:     slog.LevelInfo,\n    ClientErrorLevel: slog.LevelWarn,\n    ServerErrorLevel: slog.LevelError,\n    WithRequestBody:  true,\n    Filters: []sloggin.Filter{\n        sloggin.IgnorePath(\"\u002Fhealth\", \"\u002Fmetrics\"),\n    },\n}))\n```\n\nFor framework-specific setup, see [HTTP Middlewares](references\u002Fhttp-middlewares.md).\n\n## Backend Sinks\n\nAll follow the `Option{}.NewXxxHandler()` constructor pattern.\n\n| Category     | Packages                                                   |\n| ------------ | ---------------------------------------------------------- |\n| Cloud        | `slog-datadog`, `slog-sentry`, `slog-loki`, `slog-graylog` |\n| Messaging    | `slog-kafka`, `slog-fluentd`, `slog-logstash`, `slog-nats` |\n| Notification | `slog-slack`, `slog-telegram`, `slog-webhook`              |\n| Storage      | `slog-parquet`                                             |\n| Bridges      | `slog-zap`, `slog-zerolog`, `slog-logrus`                  |\n\n**Batch handlers require graceful shutdown** — `slog-datadog`, `slog-loki`, `slog-kafka`, and `slog-parquet` buffer records internally. Flush on shutdown (e.g., `handler.Stop(ctx)` for Datadog, `lokiClient.Stop()` for Loki, `writer.Close()` for Kafka) or buffered logs are lost.\n\nFor configuration examples and shutdown patterns, see [Backend Handlers](references\u002Fbackend-handlers.md).\n\n## Common Mistakes\n\n| Mistake | Why it fails | Fix |\n| --- | --- | --- |\n| Sampling after formatting | Wastes CPU formatting records that get dropped | Place sampling as outermost handler |\n| Fanout to many synchronous handlers | Blocks caller — latency is sum of all handlers | Use `Pool()` for concurrent dispatch |\n| Missing shutdown flush on batch handlers | Buffered logs lost on shutdown | `defer handler.Stop(ctx)` (Datadog), `defer lokiClient.Stop()` (Loki), `defer writer.Close()` (Kafka) |\n| Router without default\u002Fcatch-all handler | Unmatched records silently dropped | Add a handler with no predicate as catch-all |\n| `AttrFromContext` without HTTP middleware | Context has no request attributes to extract | Install `slog-gin`\u002F`echo`\u002F`fiber`\u002F`chi` middleware first |\n| Using `Pipe` with no middleware | No-op wrapper adding per-record overhead | Remove `Pipe()` if no middleware needed |\n\n## Performance Warnings\n\n- **Fanout latency** = sum of all handler latencies (sequential). With 5 handlers at 10ms each, every log call costs 50ms. Use `Pool()` to reduce to max(latencies)\n- **Pipe middleware** adds per-record function call overhead — keep chains short (2-4 middlewares)\n- **slog-formatter** processes attributes sequentially — many formatters compound. For hot-path attribute formatting, prefer implementing `slog.LogValuer` on your types instead\n- **Benchmark** your pipeline with `go test -bench` before production deployment\n\n**Diagnose:** measure per-record allocation and latency of your pipeline and identify which handler in the chain allocates most.\n\n## Best Practices\n\n1. **Sample first, format second, route last** — this canonical ordering minimizes wasted work and ensures all sinks see clean data\n2. **Use Pipe for cross-cutting concerns** — trace ID injection and PII scrubbing belong in middleware, not per-handler logic\n3. **Test pipelines with `slogmulti.NewHandleInlineHandler`** — assert on records reaching each stage without real sinks\n4. **Use `AttrFromContext`** to propagate request-scoped attributes from HTTP middleware to all handlers\n5. **Prefer Router over Fanout** when handlers need different record subsets — Router evaluates predicates and skips non-matching handlers\n\n## Cross-References\n\n- → See `golang-observability` skill for slog fundamentals (levels, context, handler setup, migration)\n- → See `golang-error-handling` skill for the log-or-return rule\n- → See `golang-security` skill for PII handling in logs\n- → See `golang-samber-oops` skill for structured error context with `samber\u002Foops`\n\nIf you encounter a bug or unexpected behavior in any samber\u002Fslog-\\* package, open an issue at the relevant repository (e.g., [slog-multi\u002Fissues](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-multi\u002Fissues), [slog-sampling\u002Fissues](https:\u002F\u002Fgithub.com\u002Fsamber\u002Fslog-sampling\u002Fissues)).\n",{"name":5,"paths":52,"license":15,"metadata":54,"description":7,"allowed-tools":88,"compatibility":89,"user-invocable":90},[53],"**\u002F*.go",{"author":55,"version":56,"openclaw":57},"samber","1.1.0",{"emoji":58,"install":59,"homepage":60,"requires":61,"skill-library-version":64},"?",[],"https:\u002F\u002Fgithub.com\u002Fsamber\u002Fcc-skills-golang",{"bins":62},[63],"go",{"slog-chi":65,"slog-gin":66,"slog-zap":67,"slog-echo":66,"slog-http":68,"slog-loki":69,"slog-mock":70,"slog-nats":71,"slog-otel":70,"slog-fiber":72,"slog-kafka":73,"slog-multi":74,"slog-slack":75,"slog-logrus":76,"slog-sentry":77,"slog-syslog":76,"slog-channel":78,"slog-datadog":79,"slog-fluentd":76,"slog-graylog":75,"slog-parquet":80,"slog-rollbar":81,"slog-webhook":82,"slog-zerolog":83,"slog-logstash":67,"slog-quickwit":84,"slog-sampling":85,"slog-telegram":86,"slog-formatter":87,"slog-mattermost":76,"slog-betterstack":78,"slog-microsoft-teams":81},"1.19.0","1.21.0","2.6.4","1.12.0","3.7.2","0.1.0","0.4.5","1.22.1","2.6.5","1.8.0","2.7.5","2.5.4","2.10.3","1.4.4","2.10.4","2.5.2","2.7.4","2.8.4","2.9.2","0.3.4","1.6.0","2.4.4","1.3.0","Read Edit Write Glob Grep Bash(go:*) Bash(golangci-lint:*) Bash(git:*) Agent WebFetch mcp__context7__resolve-library-id mcp__context7__query-docs AskUserQuestion Bash(godig:*) Bash(gopls:*) LSP mcp__gopls__*","Designed for Claude Code, Codex or similar harness, and for projects using Golang.",true,"main","c349be0704bffe54a7191d1412faf564b08983ca","skills\u002Fsamber-golang\u002Fgolang-samber-slog",0,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills","https:\u002F\u002Fgithub.com\u002Frockcookies","2026-11-11 22:09:57",{"source":8,"skillName":5,"commands":99,"prompt":109,"zipAvailable":90},[100,103,106],{"tool":101,"command":102},"npx","npx skills add rockcookies\u002Fskills --skill golang-samber-slog",{"tool":104,"command":105},"bunx","bunx skills add rockcookies\u002Fskills --skill golang-samber-slog",{"tool":107,"command":108},"pnpm","pnpm dlx skills add rockcookies\u002Fskills --skill golang-samber-slog","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-samber-slog\u002FSKILL.md",[111,117,121,125,129],{"path":112,"resourceType":113,"resourceTypeDesc":114,"sizeBytes":115,"sourceHtmlUrl":116},"evals\u002Fevals.json","REFERENCE","参考文档",16040,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-samber-slog\u002Fevals\u002Fevals.json",{"path":118,"resourceType":113,"resourceTypeDesc":114,"sizeBytes":119,"sourceHtmlUrl":120},"references\u002Fbackend-handlers.md",7406,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-samber-slog\u002Freferences\u002Fbackend-handlers.md",{"path":122,"resourceType":113,"resourceTypeDesc":114,"sizeBytes":123,"sourceHtmlUrl":124},"references\u002Fhttp-middlewares.md",5242,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-samber-slog\u002Freferences\u002Fhttp-middlewares.md",{"path":126,"resourceType":113,"resourceTypeDesc":114,"sizeBytes":127,"sourceHtmlUrl":128},"references\u002Fpipeline-patterns.md",8333,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-samber-slog\u002Freferences\u002Fpipeline-patterns.md",{"path":130,"resourceType":113,"resourceTypeDesc":114,"sizeBytes":131,"sourceHtmlUrl":132},"references\u002Fsampling-strategies.md",6604,"https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fsamber-golang\u002Fgolang-samber-slog\u002Freferences\u002Fsampling-strategies.md",[134,157,175,198,210,224],{"skillNo":135,"name":136,"nameZh":6,"description":137,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":138,"categories":139,"keywords":140,"publishedAt":47},"01M6WMNKD3Y4H9FGM8Q901F507","hierarchical-agents-md","init、update、audit 或 reorganize 以 AGENTS.md 与 README.md 为中心的层级项目文档： 初始化 Agent 指令、代码改动后更新文档、审计过期或冲突文档、重组仓库文档层级。","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fcustom\u002Fhierarchical-agents-md\u002FSKILL.md",[],[141,142,143,144,145,44,146,147,148,149,150,151,152,153,154,155,156],"hierarchical agents md","agents md","python","change","init","update","git","audit","文档","README","maintenance","third-party","初始化","true","for","party",{"skillNo":158,"name":159,"nameZh":6,"description":160,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":161,"categories":162,"keywords":166,"publishedAt":47},"01M6CFS6BRTQPFZCDHQP97HYXR","vueuse-functions","Apply VueUse composables where appropriate to build concise, maintainable Vue.js \u002F Nuxt features.","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvueuse\u002Fvueuse-functions\u002FSKILL.md",[163],{"categoryNo":164,"categoryName":165,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[167,168,169,170,171,172,173,174],"functions","vueuse functions","https","vue","js","nuxt","build","github",{"skillNo":176,"name":177,"nameZh":6,"description":178,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":179,"categories":180,"keywords":185,"publishedAt":47},"01M6CFS34MDQXZPAWQFE5D7VGT","vue-testing-best-practices","Use for Vue.js testing. Covers Vitest, Vue Test Utils, component testing, mocking, testing patterns, and Playwright for E2E testing.","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvuejs-ai\u002Fvue-testing-best-practices\u002FSKILL.md",[181,184],{"categoryNo":182,"categoryName":183,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":164,"categoryName":165,"taxonomyType":21,"taxonomyTypeDesc":22},[186,187,188,170,189,190,191,174,192,193,194,195,196,197,171],"best practices","vue testing best practices","testing best practices","testing","use","e2e testing","playwright","test","component","testing patterns","e2e","vitest",{"skillNo":199,"name":200,"nameZh":6,"description":201,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":202,"categories":203,"keywords":205,"publishedAt":47},"01M6CFS0N19MSJNTVM9AEQ7Z73","vue-router-best-practices","Vue Router 4 patterns, navigation guards, route params, and route-component lifecycle interactions.","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvuejs-ai\u002Fvue-router-best-practices\u002FSKILL.md",[204],{"categoryNo":164,"categoryName":165,"taxonomyType":21,"taxonomyTypeDesc":22},[206,207,170,186,174,194,208,209],"vue router best practices","router","lifecycle","navigation",{"skillNo":211,"name":212,"nameZh":6,"description":213,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":214,"categories":215,"keywords":217,"publishedAt":47},"01M6CFRYN31RFQFTE41Z6DCGKE","vue-pinia-best-practices","Pinia stores, state management patterns, store setup, and reactivity with stores.","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvuejs-ai\u002Fvue-pinia-best-practices\u002FSKILL.md",[216],{"categoryNo":164,"categoryName":165,"taxonomyType":21,"taxonomyTypeDesc":22},[218,219,186,170,220,221,222,223,174],"vue pinia best practices","pinia","state","management","state management","setup",{"skillNo":225,"name":226,"nameZh":6,"description":227,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":228,"categories":229,"keywords":237,"publishedAt":47},"01M6CFRW2DKXJHP05DYJ3P3Y2S","vue-options-api-best-practices","Vue 3 Options API style (data(), methods, this context). Each reference shows Options API solution only.","https:\u002F\u002Fgithub.com\u002Frockcookies\u002Fskills\u002Fblob\u002Fmain\u002Fskills\u002Fvuejs-ai\u002Fvue-options-api-best-practices\u002FSKILL.md",[230,231,232],{"categoryNo":164,"categoryName":165,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":233,"categoryName":234,"taxonomyType":235,"taxonomyTypeDesc":236},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[186,238,170,239,240,241,174,242,243,244],"api","vue options api best practices","data","methods","reference","only","context"]