Skip to content
logging logo

Logging

logging

Guide logging practices based on Dave Cheney's minimalist philosophy. Use when adding log.Info/Debug/Error/Warn/Fatal calls, reviewing logging code, handling errors with log+return pattern, discussing log levels, or designing error handling strategies.

SKILL.md

Full skill instructions

INSTRUCTIONS

Apply Dave Cheney's logging philosophy: simplify ruthlessly, handle errors properly, and log only what matters.

Core Principles

  1. Only Two Log Levels Matter

    • Info: For operators/​users—things they need to know during normal operation
    • Debug: For developers—controlled per-package during development
  2. Eliminate Unnecessary Levels

    LevelVerdictReason
    WarningRemove"Nobody reads warnings"—either it's an error or info
    FatalAvoidBypasses defer, prevents cleanup. Let errors bubble to main()
    ErrorRethinkIf handled, it's info. If not handled, return it to caller

    Exception: Warnings from runtimes and external libraries should be logged at warning level. You don't control these sources, and their warnings often signal deprecations or upcoming breaking changes that operators need to track.

  3. The Golden Rule of Error Logging

    "You should either handle the error, or pass it back to the caller."

    • Don't log an error AND return it (causes duplicate logs up the stack)
    • Don't log errors in library code (caller decides what to do)
    • Do let errors bubble up to where they can be meaningfully handled
  4. Terminal Error Handlers: When Error Level IS Appropriate

    At the boundary where errors become user-facing unexpected failures (e.g., 5xx responses), error-level logging is correct:

    • The error chain ends here—no caller to return to
    • The user receives a generic message (for security/​UX)
    • Operators need the full error details for debugging
    // At HTTP handler boundary - error level is appropriate
    if err != nil {
        log.Error("unexpected failure",
            "error", err,
            "request_id", requestID,
        )
        http.Error(w, "Internal Server Error", http.StatusInternalServerError)
        return
    }
    

    This is NOT the same as logging mid-stack—this is the terminal handler where errors are finally consumed, not propagated.

Review Checklist

When reviewing or writing logging code:

  • Is this log statement for users (info) or developers (debug)?
  • Am I logging an error AND returning it? (Remove the log)
  • Is this a terminal handler (5xx boundary)? (Error level is appropriate here)
  • Is this a warning? (Convert to info or error, or remove)
  • Is this Fatal/panic in library code? (Return error instead)
  • Does this log message help the operator understand system state?

Anti-Patterns to Avoid

// BAD: Log and return (duplicate logs)
if err != nil {
    log.Error("failed to connect", err)
    return err
}

// GOOD: Just return (let caller decide)
if err != nil {
    return fmt.Errorf("connect: %w", err)
}

// BAD: Warning that nobody will act on
log.Warn("connection pool running low")

// GOOD: Either info (if expected) or error (if action needed)
log.Info("connection pool at 80% capacity")

Structured Logging

When logging is appropriate, prefer structured formats:

// Prefer structured fields over string interpolation
log.Info("request completed",
    "method", r.Method,
    "path", r.URL.Path,
    "duration", time.Since(start),
)

Reference

Based on: Let's talk about logging by Dave Cheney (2015)

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View