liveBook · Manning

Monitoring

As explained in Learn Go with Pocket-Sized Projects

Logging is the practice of recording information about a program's execution for later inspection or analysis.

Logging records readable information about a program’s execution so developers can inspect state, follow events, diagnose failures, and confirm recovery. A logger records these messages, but unconditional print statements are too inflexible for production use. section 4.0

Effective logging balances diagnostic value against storage cost:

  • Write clear messages that identify what happened, rather than vague labels such as “step 1.” section 4.5
  • Record useful measures such as processing time instead of repeating reassuring completion messages. section 4.5
  • Avoid logging large maps, image data, audio data, or other unnecessary payloads; prefer sizes, presence checks, or separate storage. section 4.5
  • Choose levels and content deliberately, excluding sensitive data and clutter. section 4.5 section 4.6

Finding an unexpected count

When a count should be 1 but appears to be 2, a temporary message such as “counting entries, current value is %d” can reveal the program’s state. A reusable logger preserves this diagnostic capability without redeploying unconditional printing, and can later direct output beyond standard output. section 4.0 section 4.2

{
   "time": "2022-31-10 23:06:30.148845Z",
   "level": "warning",
   "message": "platform not scaled up for request"
}

A structured log entry makes time, severity, and message explicit, supporting later inspection and aggregation. section 4.5

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Explains logging, logger output, configurable writers, message quality, storage cost, and data-selection tradeoffs.
Examples
Uses an unexpected count, console output, configurable writers, processing duration, large data, and structured warning entries.
What you can do after
Build it from scratch as a reusable logger and select concise, meaningful messages for operational diagnosis.
How it connects
Connects logging with debugging, monitoring, testing, public APIs, persistence, and error diagnosis.

Also explained in

Compare how 40 books explain monitoring →

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.