CodeIntermediate

Add logging to code you did not write

Max Submitted by Max Added today
Here's a module I inherited and now have to support: {{paste the code}}. It currently logs {{nothing / everything at debug}}.

Propose targeted logging, not a rewrite. For each suggested line give me: the exact placement, the level, the message, and the structured fields — and one sentence on the question that log line answers at 3am.

Cover: every entry point with its inputs summarised (never the full payload), every external call with its duration and outcome, every branch where the code silently swallows a failure, and the exit with the result shape.

Hard rules: no secrets, tokens, emails or full request bodies. No logging inside a tight loop without a sample rate. Nothing at ERROR that the code recovers from on its own.

Then list the three log lines that would have the highest value if I could only add three — I'll start there.

How to use it

Ask for the three-line version and ship that first. Full instrumentation in one PR never gets reviewed properly.

Compatible popular AI tools

These tools are mapped to this prompt based on their capabilities.

People who liked this prompt

4 community likes