跳到正文
DEV Community· InApp·· 46 分鐘前AI 評分43

審計軌跡讓我明白:沒有記錄的已交付程式碼,只是寄望一切順利

Audit trails taught me that shipped code without logs is just hope

AI 導讀

作者花了三星期追查文件轉換管道的「隨機」故障,發現原因是未經驗證攔截的格式錯誤 PDF。如今每項請求均記錄輸入雜湊、偵測到的類型、轉換時間、輸出大小及錯誤代碼,讓作者能定位出錯階段。作者建議面向 Agent 的工具先做好審計記錄,再開發功能,以縮短故障排查時間。

正文

Cover image for Audit trails taught me that shipped code without logs is just hope

InApp

I spent three weeks debugging a "random" failure in my document conversion pipeline. Turns out the input wasn't random at all — it was a malformed PDF that slipped through validation, and without an audit trail of what bytes actually arrived, I was chasing ghosts in the logs.

When I built the universal converter, I assumed the hard part was parsing PDFs and DOCX files. It wasn't. It was knowing exactly what you received before you parsed it. Now every request gets an audit record: input hash, detected type, conversion time, output size, error codes. When something breaks at 3 AM, I don't guess — I look at the trail and see precisely which stage choked.

The lesson for anyone shipping agent-facing tools: your users will feed you garbage, encoded invoices, corrupted uploads, edge cases you didn't anticipate. Audit logs aren't overhead; they're the difference between a five-minute fix and a three-day hunt. Ship the logging first, before the features.

來源:DEV Community · dev.to