Using and abusing Python's logging module for more readable logs
summary
Detailed practical tweaks for production logging: uses less -S to avoid wrapping, refuses multi-line log messages and instead logs line-by-line, adds a custom log level "speaker note" and per-task log prefix that stays correct under concurrency, colorizes values by subclassing str and decorating types, wraps subprocess.run to capture stdout/stderr and also logs launches via the audit framework hook, abbreviates runaway outputs to temp files to prevent gigabyte logs — all reported as working in production.
AI-written summary · about
chapters (7)
- 0:00Introduction to logging
- 1:33Best practices for logging
- 2:55Async and advanced logging
- 4:24Customizing log output
- 6:43Subprocess tracking
- 8:44Handling large logs
- 10:10Exceptions and conclusion
related talks
29mLogging the right way
12mDebugging Python in Production: Practical Techniques Beyond Print Statements
31mDevelopers Have the Logs Their Imagination Allows
30mEffortless Logging: A deep dive into the logging module
29mApplication Logging
38mSyslog-ng for DevOps: Customized Logging with Python
38mLogging as a Painkiller
44mLogging and Exception Handling for Django
