===== Debug ===== Env Variables ============= There are few ENV Variables that can be used to force some debugging features; **TERMTK_FILE_LOG** - Log to a file --------------------------------- To force logging to a file (i.e. "**session.log**") .. code:: bash TERMTK_FILE_LOG=session.log python3 demo/demo.py **TERMTK_STACKTRACE** - Force stacktrace generation with CTRL+C -------------------------------------------------------------- Use this env variable to force a stacktrace generation to the file defined (i.e. "**stacktrace.txt**") .. code:: bash TERMTK_STACKTRACE=stacktrace.txt python3 demo/demo.py **TERMTK_FORCESERIAL** - Force some workaround to pickup the terminal size from the serial console -------------------------------------------------------------- Use this env variable if pyTermTk is running on a serial console .. code:: bash TERMTK_FORCESERIAL=1 python3 demo/demo.py Gui === `Visual Studio Code `_ ----------------------------------------------------- vsCode debug feature comes out of the box, it only require the default `**Python** `_ extension installed .. image:: https://github.com/ceccopierangiolieugenio/pyTermTk/assets/8876552/00eab373-c347-45ab-8c40-0b023135946c :alt: vsCode debug `intellij IDEA `_ --------------------------------------------------------------------------- I haven't tried it recently since my vsCode experience is silk smooth but based on the results of the `issue 102 `_ I am pretty confident that intellij debug feature should work as well `PyCharm `_ ----------------------------------------------- Same for PyCharm, I mean, I tried both those IDEs at least once. Profiling ========= `VizTracer `_ -------------------------------------------------- .. image:: https://github.com/ceccopierangiolieugenio/pyTermTk/assets/8876552/34ff9b77-f01b-45bd-a57e-971c7b68c4a2 this tool is able to generate a tracker file that can be viewed using `Perfetto `_ (`UI `_) .. code:: bash # install cprofilev: # pip3 install viztracer viztracer --tracer_entries 10000010 tests/paint.py # View the results # loading the "result.json" in https://ui.perfetto.dev # or running vizviewer result.json `cProfile `_, `cProfilev `_ ------------------------------------------------------------------------------------------------------------------ .. code:: bash python3 -m cProfile -o profiler.bin tests/test.ui.004.py # install cprofilev: # pip3 install cprofilev cprofilev -f profiler.bin # open http://127.0.0.1:4000 `py-spy `_ --------------------------------------------- .. code:: bash # install pip install py-spy # run the application python3 demo/demo.py # on another terminal run the py-spy sudo env "PATH=$PATH" \ py-spy top \ --pid $(ps -A -o pid,cmd | grep demo.py | grep -v grep | sed 's,python.*,,') pyroscope --------- `pyroscope `_ can be used as well (I guess) for profiling