make some log formatting conditional in an error case