fixed up log writing so it happens after parse failure