~/talk

Using and abusing Python's logging module for more readable logs

Talkat PyBay 2024 · on Saturday, 2024-09-21· [python, developer-experience]
links:none on file
slides:none on file

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

  1. 0:00Introduction to logging
  2. 1:33Best practices for logging
  3. 2:55Async and advanced logging
  4. 4:24Customizing log output
  5. 6:43Subprocess tracking
  6. 8:44Handling large logs
  7. 10:10Exceptions and conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.