Python Logging and Tracing Cheat Sheet/Turn warnings into errors

Catch deprecated or risky behavior early.

Section: Warnings and Execution Traces

Turn warnings into errors

bash
bash
python -W error app.py

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Warnings and Execution Traces
Force warnings to appear
Promote useful warnings during development.
OpenIn sheetpythonsame section
Trace executed lines
Run a script and print executed lines.
OpenIn sheetbashsame section
Count executed lines
Collect line execution counts for scripts.
OpenIn sheetbashsame section
Create a module logger
Use a named logger per module.
Dump traceback later with faulthandler
Emit stack traces after a timeout to catch hangs.
Log to a file
Persist logs to disk for debugging after process exit.