liveBook · Manning

Clear log message

As explained in Learn Go with Pocket-Sized Projects

A clear log message states the relevant event or result precisely enough to explain program behavior later.

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

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Explains clear messages through contrasting examples and a length-limit exercise, without defining a complete logging policy.
Examples
Uses step labels, database insertion, email sending, processing time, map size, and a 1,000-character limit.
What you can do after
Apply it by writing event-specific messages and limiting unnecessary payload detail.
How it connects
Connects clear log messages to logging, log storage, function execution, and data-size management.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.