factored out logger code