Code clean up for activity logging
Code clean up for activity logging

  * Consolidated common functionality
  * Added a try/catch block so that issues in writing event don't turn into problems responding to request

materials-commons/materialscommons.org,materials-commons/materialscommons.org,materials-commons/materialscommons.org,materials-commons/materialscommons.org,materials-commons/materialscommons.org