Agent skill

Logging

Standards for structured logging and observability in Golang.

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/logging

Metadata

Additional technical details for this skill

labels
golang logging slog zap observability
triggers
{
    "files": [
        "go.mod",
        "pkg/logger/**"
    ],
    "keywords": [
        "logging",
        "slog",
        "structured logging",
        "zap"
    ]
}

SKILL.md

Golang Logging Standards

Priority: P1 (STANDARD)

Principles

  • Structured Logging: Use JSON or structured text. Readable by machines and humans.
  • Leveled Logging: Debug, Info, Warn, Error.
  • Contextual: Include correlation IDs (TraceID, RequestID) in logs.
  • No log.Fatal: Avoid terminating app inside libraries. Return error instead. Only main should exit.

Libraries

  • log/slog (Recommended): Stdlib since Go 1.21. Fast, structured, zero-dep.
  • Zap (uber-go/zap): High performance, good if pre-1.21 or extreme throughput needed.
  • Zerolog: Zero allocation, fast JSON logger.

Guidelines

  • Initialize logger at startup.
  • Inject logger or use a global singleton configured at startup (pragmatic choice).
  • Use slog.Attr for structured data.

References

  • Slog Patterns

Expand your agent's capabilities with these related and highly-rated skills.

Didn't find tool you were looking for?

Be as detailed as possible for better results