Add logging to database.py