Better logging of failure in the task_logger (#2940)

* logging task_logger failure

* format

* clippy fxes

* cleanup

* address comments
This commit is contained in:
Cheick Keita
2023-04-05 17:38:11 -07:00
committed by GitHub
parent f19a0e8d70
commit d27d815d92
2 changed files with 14 additions and 7 deletions

View File

@ -64,10 +64,12 @@ async fn validate_libfuzzer(config: ValidationConfig) -> Result<()> {
let libfuzzer = LibFuzzer::new( let libfuzzer = LibFuzzer::new(
&config.target_exe, &config.target_exe,
config.target_options.clone(), config.target_options.clone(),
config.target_env.into_iter().collect(), config.target_env.iter().cloned().collect(),
config config
.setup_folder .setup_folder
.unwrap_or(config.target_exe.parent().unwrap().to_path_buf()), .clone()
.or_else(|| config.target_exe.parent().map(|p| p.to_path_buf()))
.expect("invalid target_exe"),
None::<&PathBuf>, None::<&PathBuf>,
MachineIdentity { MachineIdentity {
machine_id: Uuid::nil(), machine_id: Uuid::nil(),
@ -103,10 +105,12 @@ async fn get_logs(config: ValidationConfig) -> Result<()> {
let libfuzzer = LibFuzzer::new( let libfuzzer = LibFuzzer::new(
&config.target_exe, &config.target_exe,
config.target_options.clone(), config.target_options.clone(),
config.target_env.into_iter().collect(), config.target_env.iter().cloned().collect(),
config config
.setup_folder .setup_folder
.unwrap_or(config.target_exe.parent().unwrap().to_path_buf()), .clone()
.or_else(|| config.target_exe.parent().map(|p| p.to_path_buf()))
.expect("invalid setup_folder"),
None::<&PathBuf>, None::<&PathBuf>,
MachineIdentity { MachineIdentity {
machine_id: Uuid::nil(), machine_id: Uuid::nil(),

View File

@ -422,8 +422,8 @@ impl TaskLogger {
}) => break, }) => break,
Ok(c) => c, Ok(c) => c,
Err(e) => { Err(e) => {
error!("{}", e); error!("task logger failure {}", e);
break; return Err(e);
} }
}; };
} }
@ -440,7 +440,10 @@ pub struct SpawnedLogger {
impl SpawnedLogger { impl SpawnedLogger {
pub async fn flush_and_stop(self, timeout: Duration) -> Result<()> { pub async fn flush_and_stop(self, timeout: Duration) -> Result<()> {
let _ = tokio::time::timeout(timeout, self.logger_handle).await; if let Ok(Err(e)) = tokio::time::timeout(timeout, self.logger_handle).await {
error!("failed to flush and stop task logger {}", e);
return Err(e.into());
}
Ok(()) Ok(())
} }
} }