CRM-15270 - cleaning code and future proofing on lobo's suggestion

See https://github.com/civicrm/civicrm-core/pull/4090/files#r17368220

----------------------------------------
* CRM-15270: Enabling logging result in database error
  https://issues.civicrm.org/jira/browse/CRM-15270