I want to check the body of the HTTPS POST request I’m handling in a plugin.
The indico.log file shows the POST request with the source IP, however, it dosen’t show the request body.
Here is the relevant record from the indico.log file -
2023-04-26 10:11:51,551 INFO fccd33c5ab0640ss - indico.rh POST /<plugin>/<route>/post [IP=<source IP>] [PID=1234]
How do I log the detailed request BODY?
Secondly, I want to know if indico logs the database queries? This above HTTP handler should ideally trigger the register_transaction()
function after verifying if the registration exist -
self.registration = Registration.query.filter_by(id = TransId[1], event_id = TransId[0]).first()
So how do I find out the db query logs? or if they don’t exist, is there an indico way of loggin them?
Appreciate any help, thanks!
The bin/utils/db_log.py
script is your friend for logging DB queries, and for logging POST data I suggest simply using print(request.form)
- you are on a development setup, right?
Thanks for your prompt response. Yes, I’m on a dev setup, but cannot test the functionality on local, so have to test it after deploying on dev server. I modified the bin/utils/db_log.py
LogRecordStreamHandler script to log all the messages in a text file instead of printing on console. So hopefully this shold log all the db queries, right?
Regarding logging the POST body data, did you mean I should just write it to a saperate log file within the handler?, or can I modify the default logging method in anyway to include request BODY in the indico.log file?
Thanks!
Sure, look for the place where it gets logged and include it there. I do not recommend this though, since it will also log sensitive data like the password during login…