xiaohongshu
xiaohongshu
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.
Full skill instructions
Apply Dave Cheney's logging philosophy: simplify ruthlessly, handle errors properly, and log only what matters.
Only Two Log Levels Matter
Eliminate Unnecessary Levels
| Level | Verdict | Reason |
|---|---|---|
| Warning | Remove | "Nobody reads warnings"—either it's an error or info |
| Fatal | Avoid | Bypasses defer, prevents cleanup. Let errors bubble to main() |
| Error | Rethink | If 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.
The Golden Rule of Error Logging
"You should either handle the error, or pass it back to the caller."
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:
// 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.
When reviewing or writing logging code:
Fatal/panic in library code? (Return error instead)// 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")
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),
)
Based on: Let's talk about logging by Dave Cheney (2015)
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
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...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
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...
Display project status, active tracks, and next actions
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.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience