Structured logging with trace context
You're adding a structured logging helper to a Node/TypeScript service so logs flow cleanly into Datadog. You want an AI agent to write a `createLogger(context)` wrapper around `pino` that emits JSON, attaches a request-scoped trace ID, and redacts known PII fields. Write the prompt/spec you'd hand the agent so the result is correct on the first try — including the constraints, edge cases, and acceptance criteria. Then explain what a lazy one-line prompt ("write me a logger") would get wrong here.
redact_log_fields(entries: list[str], redact_keys: list[str]) → list[str][["msg=login ok","user.password=hunter2","req.headers.authorization=Bearer abc"],["password","authorization"]]out["msg=login ok","user.password=[REDACTED]","req.headers.authorization=[REDACTED]"][["payment.card.number=4111111111111111"],["card"]]out["payment.card.number=[REDACTED]"]Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.