golang-logging
БесплатноБез исполняемых скриптовНе проверенStandards for structured logging and observability in Golang. Use when adding structured logging or tracing to Go services.
от HoangNguyen0403★ 598 звёзд на GitHubОб этом скилле
Golang Logging Standards
Priority: P1 (HIGH)
Principles
- Structured Logging: Use JSON or structured key-value attributes. Machine-readable and filterable.
- One Log Owner: Each request, job, or CLI invocation has exactly one boundary that logs its failures—usually where the error is handled or translated. Choose it by responsibility, not a fixed layer. Deeper helpers wrap and return without logging.
- Typed Context Keys: Use a private typed key (
type ctxKey string) and an accessor for both storing and reading request-scoped values. Never mix string and typed keys for the same value. - Context-Aware Logging: Pass
ctxtoInfoContext/ErrorContext/WarnContext. Context alone does not add attributes unless the handler is built to read them; attach correlation IDs withslog.Withfrom the typed accessor. - Business Traceability vs PII Redaction: Include only approved non-sensitive identifiers (e.g. tenant ID, organization code, order number). Strictly redact credentials, API tokens, passwords, and sensitive PII. Free-form and joined error text is not automatically scrubbed.
- Leveled Logging: Debug, Info, Warn, Error.
- No
log.Fatal: Avoid terminating apps inside libraries. Return errors instead; onlymain()should handle process exit.
Libraries
log/slog(Recommended Stdlib): Stdlib since Go 1.21. Fast, structured, zero-dep.- Zap (
uber-go/zap): Production-grade structured logger for high-throughput microservices. - Zerolog: Zero allocation, fast JSON logger.
Workflow: Set Up Structured Logging
- Initialize structured logger at startup in
main()with standard JSON output. - Inject request correlation IDs (TraceID, RequestID) via middleware using typed context keys.
- Pass logger via context (
logger.FromContext(ctx)) or constructor injection. - Log once at the chosen owner; wrap errors in helpers without intermediate logging.
See slog setup and usage examples
Anti-Patterns
- No Double-Logging: Do not log an error in a repository/database helper AND log it again at the owner.
- No log-and-rethrow into another logger: If a boundary logs, do not pass the same failure to a layer that logs it again.
- No fmt.Println in production: Use structured, leveled loggers.
- No Untyped Context Keys: Avoid
context.WithValue(ctx, "logger", l)andctx.Value("trace_id")with raw string keys. - No Secrets in Logs: Redact bearer tokens, passwords, and sensitive personal info.
- No log.Fatal in libraries: Return errors; only
main()should callos.Exit.
References
Установить golang-logging в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл golang-logging?
Standards for structured logging and observability in Golang. Use when adding structured logging or tracing to Go services.
Как установить скилл golang-logging?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл golang-logging запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic