From 47751f3875516efc710cf7a75fb688ac6b73f9c7 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 30 Sep 2023 17:52:58 -0500 Subject: [PATCH] Downgrade some WARN logs to INFO, update docs for public methods --- src/lib.rs | 7 ++++--- src/middleware/internal.rs | 4 +++- src/repo/migrate.rs | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 365ad80..5bcf6a6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1961,6 +1961,10 @@ impl PictRsConfiguration { Ok(self) } + /// Install the configured pict-rs metrics collector + /// + /// This is a no-op if pict-rs is not configured to export metrics. Applications that register + /// their own metrics collectors shouldn't call this method. pub fn install_metrics(self) -> color_eyre::Result { if let Some(addr) = self.config.metrics.prometheus_address { PrometheusBuilder::new() @@ -1972,9 +1976,6 @@ impl PictRsConfiguration { } /// Run the pict-rs application - /// - /// This must be called after `init_config`, or else the default configuration builder will run and - /// fail. pub async fn run(self) -> color_eyre::Result<()> { let PictRsConfiguration { config, operation } = self; diff --git a/src/middleware/internal.rs b/src/middleware/internal.rs index 66c2fe0..1d47639 100644 --- a/src/middleware/internal.rs +++ b/src/middleware/internal.rs @@ -98,7 +98,9 @@ where fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { match self.as_mut().project() { InternalFutureProj::Internal { future } => future.poll(cx), - InternalFutureProj::Error { error } => Poll::Ready(Err(error.take().unwrap().into())), + InternalFutureProj::Error { error } => { + Poll::Ready(Err(error.take().expect("Polled after completion").into())) + } } } } diff --git a/src/repo/migrate.rs b/src/repo/migrate.rs index 8083696..5eea7e2 100644 --- a/src/repo/migrate.rs +++ b/src/repo/migrate.rs @@ -20,7 +20,7 @@ const GENERATOR_KEY: &str = "last-path"; #[tracing::instrument(skip_all)] pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result<(), Error> { - tracing::warn!("Running checks"); + tracing::info!("Running checks"); if let Err(e) = old_repo.health_check().await { tracing::warn!("Old repo is not configured correctly"); return Err(e.into()); @@ -32,8 +32,8 @@ pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result let total_size = old_repo.size().await?; let pct = (total_size / 100).max(1); - tracing::warn!("Checks complete, migrating repo"); - tracing::warn!("{total_size} hashes will be migrated"); + tracing::info!("Checks complete, migrating repo"); + tracing::info!("{total_size} hashes will be migrated"); let hash_stream = std::pin::pin!(old_repo.hashes()); let mut hash_stream = hash_stream.into_streamer(); @@ -51,7 +51,7 @@ pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result if index % pct == 0 { let percent = index / pct; - tracing::warn!("Migration {percent}% complete - {index}/{total_size}"); + tracing::info!("Migration {percent}% complete - {index}/{total_size}"); } } @@ -61,7 +61,7 @@ pub(crate) async fn migrate_repo(old_repo: ArcRepo, new_repo: ArcRepo) -> Result .await?; } - tracing::warn!("Migration complete"); + tracing::info!("Migration complete"); Ok(()) } @@ -73,7 +73,7 @@ pub(crate) async fn migrate_04( store: S, config: Configuration, ) -> Result<(), Error> { - tracing::warn!("Running checks"); + tracing::info!("Running checks"); if let Err(e) = old_repo.health_check().await { tracing::warn!("Old repo is not configured correctly"); return Err(e.into()); @@ -89,8 +89,8 @@ pub(crate) async fn migrate_04( let total_size = old_repo.size().await?; let pct = (total_size / 100).max(1); - tracing::warn!("Checks complete, migrating repo"); - tracing::warn!("{total_size} hashes will be migrated"); + tracing::info!("Checks complete, migrating repo"); + tracing::info!("{total_size} hashes will be migrated"); let mut hash_stream = old_repo.hashes().await.into_streamer(); @@ -117,7 +117,7 @@ pub(crate) async fn migrate_04( if index % pct == 0 { let percent = index / pct; - tracing::warn!("Migration {percent}% complete - {index}/{total_size}"); + tracing::info!("Migration {percent}% complete - {index}/{total_size}"); } } } @@ -129,7 +129,7 @@ pub(crate) async fn migrate_04( if index % pct == 0 { let percent = index / pct; - tracing::warn!("Migration {percent}% complete - {index}/{total_size}"); + tracing::info!("Migration {percent}% complete - {index}/{total_size}"); } } @@ -145,7 +145,7 @@ pub(crate) async fn migrate_04( .await?; } - tracing::warn!("Migration complete"); + tracing::info!("Migration complete"); Ok(()) }