Choosing Context for Diagnostic Logs
A diagnostic message is useful when it connects a relevant operation with the observed state and a clear result.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Choose a compact record
For a batch importer, a row number and field name can identify invalid numeric data without copying the whole source record into the log. Keep source numbering with enumeration.
Correlate repeated steps
If one job loads and processes many rows, give messages a job identifier so interleaved runs can be separated. An operation's observable inputs and outputs determine which detail is necessary to reproduce an ordinary failure.[1]
Follow one record across several phases without storing its contents
An importer can report that record R12 failed validation after successful decoding. A phase name, stable record ID and bounded reason make the failure traceable without reproducing the full record in logs. See file errors by stage.
start run=R phase=decode
record run=R item=R12 phase=validate outcome=reject reason=range
finish run=R accepted=18 rejected=1
Check logs on a real failure shape
Record keys and reason fields should distinguish two failures that require different responses. Avoid treating the presence of one log line as proof of a successful transaction. Test diagnostics with synthetic sensitive fields and ensure they are excluded where required.