Fix some annoying misalignment in logging output, and only flush if we got log