From 7872771aeea9f464ffa8a703571a11883e8d97c0 Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Sat, 15 Jun 2024 19:45:53 -0700 Subject: [PATCH] clean up sync log --- bin/core/src/helpers/sync/deployment.rs | 26 +++++++++++++++++++------ bin/core/src/helpers/sync/file.rs | 3 ++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/bin/core/src/helpers/sync/deployment.rs b/bin/core/src/helpers/sync/deployment.rs index f5d96dc02..e6b752f98 100644 --- a/bin/core/src/helpers/sync/deployment.rs +++ b/bin/core/src/helpers/sync/deployment.rs @@ -476,8 +476,7 @@ pub async fn run_updates( } let mut has_error = false; - let mut log = - format!("running updates on {}s", Deployment::resource_type()); + let mut log = String::new(); // Collect all the deployment names that need to be deployed // and their 'after' dependencies @@ -625,17 +624,32 @@ pub async fn run_updates( } } - let stage = format!("Update {}s", Deployment::resource_type()); let mut logs = Vec::with_capacity(1); + + let stage = format!("Update {}s", Deployment::resource_type()); if has_error { + let log = format!( + "running updates on {}s{log}", + Deployment::resource_type() + ); logs.push(Log::error(&stage, log)); return Some(logs); - } else { + } else if !log.is_empty() { + let log = format!( + "running updates on {}s{log}", + Deployment::resource_type() + ); logs.push(Log::simple(&stage, log)); } - let mut log = - String::from("running executions to sync deployment state..."); + if to_deploy.is_empty() { + return Some(logs); + } + + let mut log = format!( + "{}: running executions to sync deployment state", + muted("INFO") + ); let mut round = 1; while !to_deploy.is_empty() { diff --git a/bin/core/src/helpers/sync/file.rs b/bin/core/src/helpers/sync/file.rs index 8a4d3123a..878cdbfc4 100644 --- a/bin/core/src/helpers/sync/file.rs +++ b/bin/core/src/helpers/sync/file.rs @@ -9,7 +9,8 @@ pub fn read_resources( path: &Path, ) -> anyhow::Result<(ResourcesToml, Log)> { let mut res = ResourcesToml::default(); - let mut log = format!("reading resources from {path:?}"); + let mut log = + format!("{}: reading resources from {path:?}", muted("INFO")); read_resources_recursive(path, &mut res, &mut log).with_context( || format!("failed to read resources from {path:?}"), )?;