Fix logging when deleting objects

* Gather `log_json` content before `flush` -- otherwise, deleted objects
  (especially objects deleted due to cascading) cause errors when
  attempting to build `Revision` objects (since the objects are gone
  from the database and marked "dirty" in Python).
Merge pull request #730 from reciprocity/feature/fix-log-on-delete

Fix logging when deleting objects