Log operation to database (not working)