Qikuyueser.com

Write a Log Line That Explains What Happened

Added 2026-11-02

Context, searchable, answers why this one failed.

I am adding logs to a flow (described below). Do: 1) list the fields this line must carry — event, subject, result, duration, correlation ID; 2) write a sample line and explain why each field matters; 3) point out which fields leak sensitive data and need masking; 4) list the questions this single line should answer; 5) warn me what happens when the log level is wrong. Do not over-log.
Site original

Chinese original

Open in ChatGPT
How to use

好的日志是写给三个月后半夜排错的自己。

Try tweaking it

  • Have it restate requirements and constraints before writing code.
  • Ask for the smallest change plus a rollback path, not a full-file rewrite.

What you should get

  • A minimal, runnable change with copy-ready code
  • Impact list: which files and call sites must follow

Common mistakes

  • Asking it to touch ten files at once, then losing track of what broke what.
  • Pasting only the error, with no code or version, and getting an unfixable answer.

How to check the output

  • The change runs, can be rolled back, and touches nothing unrelated.
  • Edge cases (empty, oversized, concurrent) are covered or explained.

Where it works

  • Good for: having it restate requirements and constraints, then propose the smallest runnable change.
  • Watch out: include versions and a minimal reproduction with the error, or the fix may look plausible but not fit.

More in this topic