python logging handler for capturing logs in a database