Merged in logging to sqlite db code