Using and abusing Python's logging module for more readable logs
summary
Custom log level speaker note marks reminders; a log-prefix context injects stable prefixes so interleaved async output still groups correctly; color comes from a string subclass plus a decorator to emit ANSI codes; path objects get sanitized by a replace new lines policy that swaps surprising newlines for visible glyphs; every subprocess invocation is recorded (and stdout/stderr captured) via a wrapper plus Python’s audit framework; huge outputs are abbreviated and full data written to temp files.
AI-written summary · about
chapters (11)
- 0:00Introduction to logging
- 1:27Using less for log viewing
- 2:09Avoiding newlines in logs
- 2:53Debug level and code logging
- 3:55Async logging with prefixes
- 4:36Colorizing log output
- 5:38Processing log values
- 7:04Logging subprocesses
- 8:47Abbreviating long logs
- 10:10Exception logging
- 10:31Conclusion and takeaways
related talks
30mEffortless Logging: A deep dive into the logging module
31mDevelopers Have the Logs Their Imagination Allows
38mSyslog-ng for DevOps: Customized Logging with Python
45mLightning talks
24m"A Confession of My Python Sins"
44mLogging and Exception Handling for Django
21mlogger.info(f"Don't Give all your {secrets} away")
50mHow I built a power debugger out of the standard library and things I found on the internet
