Much more efficient logging to db (one write per second), server now takes database name as argument