Perhaps just a config file option to start. This may be handy in the field, particularly if coupled with solid pdb log <-> postgres log correlation ids, but it also makes it much easier to capture queries (e.g. console queries, etc.) for testing (performance, etc.).
Include the correlation ID as part of this work if it's straightforward, otherwise let's create another ticket.