code for database logger