add log + error management at flush