Spec a pino logger with request ids and redaction

Vibe codingMedium25 min

Your task

Your Node and TypeScript API logs with console.log, and the logs reach Datadog as plain text. Nobody can follow one request through them, and a support engineer recently found a customer's password in a log line. An agent will write a logger module on top of pino and move the service to it.

Write the spec you would hand the agent.

What you know:

  • Express 4 on Node 22; the load balancer sets an x-request-id header on every request
  • logs go to stdout, and the Datadog agent ships them
  • your Datadog setup reads a field named level as the status when it holds a name such as info
  • request bodies include password, token and card fields, sometimes nested one level deep

Then, in a few sentences: what does "write me a logger" get wrong?