Fix log capture on py3