Reputation: 153
I am using pdb.set_trace()
as a breakpoint in my python function during Odoo development and I keep getting the log messages.
pdb.set_trace()
-> if s['confirm_state'] in ['draft','confirmed']:
(Pdb) 2015-04-05 05:40:12,794 9981 INFO vvm_odoo_new werkzeug: 127.0.0.1 - - [05/Apr/2015 05:40:12] "POST /longpolling/poll HTTP/1.1" 200 -
2015-04-05 05:40:47,769 9981 INFO vvm_odoo_new werkzeug: 127.0.0.1 - - [05/Apr/2015 05:40:47] "POST /longpolling/poll HTTP/1.1" 200 -
I first thought that it was because of the instant messaging feature and so I un-installed it. But I still keep getting this message.
This does not stop me from using the pdb stack trace but the problem here is that this terminal message keeps showing up in between the typing in the pdb trace point.
Upvotes: 3
Views: 1738
Reputation: 9670
I recommend you to install the Visual Studio Code to debug Odoo:
Visual Studio Code is a source code editor developed by Microsoft for Windows, Linux and macOS. It includes support for debugging, embedded Git control, syntax highlighting, intelligent code completion, snippets, and code refactoring. It is free and open-source, although the official download is under a proprietary license.
First, you need to install the Python Extension within VSCode. Then, if you want to start debugging you just need to click on the Debug button and click on the wheel on the top of the sidebar. The file launch.json
will open and you just need to add this element to the bottom.
{
"name": "Python: Odoo",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"console": "externalTerminal",
"program": "/odoo_path/odoo.py",
"args": [
"--config=/odoo_config_path/.odoo_8.conf",
],
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
Once it is added you already can run Odoo under VSCode. For more information about the launch configurations click here
Now you can create breakpoint as usual. You can use the debugger console as well. And if you use the property: "console": "externalTerminal"
as I did, you can show the log in an external console at the same time
Upvotes: 0
Reputation: 33
You can add the --logfile=<logfile>
to the parameters when you launch Odoo - which will send standard Odoo log messages to that file, with the debugger log left nice and clean.
i.e. I have a bash script in /usr/local/bin which calls:
python /path/to/odoo/odoo.py --addons-path=/path/to/addons,/path/to/custom/addons "$@"
The $@
tells the script to accept any additional params on the end, so when I call:
odoo --logfile=~/odoospam.log
I can debug nice and tidy.
Then if you want to check the log just tail -f ~/odoospam.log
.
Still trying to figure out the best way to debug with pdb inside a docker container, will update this when I find a suitable way of doing it.
EDIT:
Found how to do so in docker (Kudos to https://stackoverflow.com/users/941605/jamey): Docker-compose and pdb
docker-compose run --service-ports odoo
Upvotes: 2