A clear log message states what happened precisely enough to explain program behavior later. Replace vague messages such as “step 1” with the event or result that matters. section 4.5
Useful messages should:
- Identify the actual event, such as inserting a document or sending an email. section 4.5
- Record valuable context, such as how long a function took to process. section 4.5
- Avoid dumping large values; log a map’s size or whether a key exists instead. section 4.5
From vague to useful
Replace “step 1” with a message such as “document inserted in database,” then add processing duration when that context helps diagnose behavior. section 4.5
{
"time": "2022-31-10 23:06:30.148845Z",
"level": "warning",
"message": "platform not scaled up for request"
}
A structured log entry separates time, severity, and a specific message: “platform not scaled up for request.” section 4.5
