In most files the first two lines for logging should already be present. The string 'gajim.groupchat_control' depends on the part of Gajim you're working with.
Starting Gajim with gajim -l gajim=DEBUG will enable full debug logging, while gajim -l gajim.groupchat_control=DEBUG will limit log output to that specific part of Gajim. Read more about log levels.
The IPython interface
Helpful to see Gajim internals at runtime. IPython interface is documented here.
An actual debugger!
If you have at least Python 3.7 you can just insert
somewhere in the code and it will drop you into the pdb debugger. You can find the documentation for that here. If you're using an older version of Python the command is not quite as convenient but it should still work. Just use
import pdb; pdb.set_trace()
instead of breakpoint().
An even nicer debugger: PyCharm
Getting PyCharm to work with Gajim is pretty easy. Just load the cloned folder as a project. Then:
Go to File -> Settings then Project: gajim -> Project Interpreter
Click on the gear in the top right icon and Add... to add a new interpreters
Select Existing environment and then choose [...]/venv/bin/python in your virtual environment. This will get the right environment set up. Next we need to tell PyCharm how to launch Gajim.
Go to Run -> Edit Configurations.... There is sometimes a weird bug and this entry is disabled. In that case just hit Run -> Run... and then a window offering only Edit Configurations... should show up.
Hit the + on the top left and select Python and give it a nice name.
Also select the "launch.py" script for Script path: and put
-p testprofile -c ../config -s -l gajim=DEBUG"
into the Parameters: box.
That's it! Now you can explore the code and put breakpoints in it and then just hit the little bug button to run this configuration in debug mode and it will stop on your breakpoints and allow you to step.