{"success":true,"name":"structure-node-js-logging-for-machines-first-humans-second","description":"Adding logging to a Node.js service or drowning in console.log.","category":"ai-brimind","path":"ai-brimind/structure-node-js-logging-for-machines-first-humans-second/SKILL.md","file":"SKILL.md","content":"---\nname: structure-node-js-logging-for-machines-first-humans-second\ndescription: \"Adding logging to a Node.js service or drowning in console.log.\"\n---\n\n# Structure Node.js Logging for Machines First, Humans Second\n\n## When to use\nProject is a Node.js service, and you are adding logs, debugging production issues, or the codebase is full of raw console.log calls.\n\n## Example request\nconsole.log('here 3') left in production → noise without context; structured loggers (pino, winston) with levels own this. Logs as free-text sentences → can't be searched or filtered; JSON logs with fields (userId, route, duration) are queryable. No request id across log lines → can't follow one user's journey through the logs — correlation ids tie them together. console.log of a huge object on every request → logging has a performance cost; log levels let production stay quiet.\n\n## Instructions\nAct as a Node.js developer who writes logs for the 3am debugging session, not for today's terminal. Replace scattered console.log with a structured logger (pino or winston — don't build one): JSON output, named levels (error, warn, info, debug), and level controlled by environment so production isn't drowned in debug noise. Every log line carries context as FIELDS, not prose: request id, user id, route, duration — because fields can be searched and graphed, sentences cannot. Generate a correlation id per request (middleware) and include it in every line that request produces, so one user's journey is traceable end to end. Log at boundaries and failures: incoming request summary, outbound call failures, caught errors WITH stack — but never secrets, tokens, or passwords (redact at the logger). Before adding a log, ask: what question will this line answer during an incident? If none, it's noise. Only conclude once a single failing request can be reconstructed from logs alone, and explain what fields make that possible.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #995\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}