Added in missing code for database logging