setting-up-logging
Setting Up Logging
Rotating file logging, colored stdout logging, and colored non-log output. Uses colorlog for prefix-only coloring (log prefix is colored, message text stays default).
Copy shared/logging/.
Key Principle
File logging is always on — it's the durable record for post-mortem debugging. Stdout is lost on terminal close; file logs survive.
Stdout logging is for modes where no human reads stdout directly. When you launch a GUI app from terminal or run a server in a container, stdout logs are useful — they show real-time output during development and serve as container log transport (Docker/systemd capture stdout).
CLI tools must NOT use stdout logging — stdout is the user interface. Log lines mixed into stdout corrupt the output (imagine mytool | grep something with log lines). Use write_info/write_error for user-facing messages instead.
| Mode | File log | Stdout log | Non-log colored output |
|---|---|---|---|
| CLI tool | Always | Never | write_info, write_error for user messages |