From 2be9b6541d140386ca670f521b5a9870c4e9a167 Mon Sep 17 00:00:00 2001 From: glendc Date: Mon, 30 Sep 2024 19:59:38 +0200 Subject: [PATCH] expose main trace events as info/warn (0.2.2) --- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- src/shutdown.rs | 18 +++++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94fef34..09de61d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +# 0.2.2 (30. September, 2024) + +Expose main trace events at Info level for increased visibility, +log-directives can be used by dependencies +to filter out tokio-graceful info events if not desired. + # 0.2.1 (30. September, 2024) Expose a signal that can be awaited on without awaiting the configured diff --git a/Cargo.toml b/Cargo.toml index 648230e..7c49e6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ categories = ["asynchronous", "network-programming"] edition = "2021" name = "tokio-graceful" -version = "0.2.1" +version = "0.2.2" description = "util for graceful shutdown of tokio applications" homepage = "https://github.com/plabayo/tokio-graceful" readme = "README.md" diff --git a/src/shutdown.rs b/src/shutdown.rs index 61603a1..ef2cec7 100644 --- a/src/shutdown.rs +++ b/src/shutdown.rs @@ -388,12 +388,12 @@ impl Shutdown { /// [`ShutdownGuard`]: crate::ShutdownGuard /// [`Duration`]: std::time::Duration pub async fn shutdown(mut self) -> time::Duration { - tracing::trace!("::shutdown: waiting for signal to trigger (read: to be cancelled)"); + tracing::info!("::shutdown: waiting for signal to trigger (read: to be cancelled)"); let weak_guard = self.guard.downgrade(); let start: time::Instant = time::Instant::now(); tokio::select! { _ = weak_guard.cancelled() => { - tracing::trace!("::shutdown: waiting for all guards to drop"); + tracing::info!("::shutdown: waiting for all guards to drop"); } _ = &mut self.zero_overwrite_rx => { let elapsed = start.elapsed(); @@ -406,7 +406,7 @@ impl Shutdown { tokio::select! { _ = self.zero_rx => { let elapsed = start.elapsed(); - tracing::trace!("::shutdown: ready after {}s", elapsed.as_secs_f64()); + tracing::info!("::shutdown: ready after {}s", elapsed.as_secs_f64()); elapsed } _ = self.zero_overwrite_rx => { @@ -437,19 +437,19 @@ impl Shutdown { mut self, limit: time::Duration, ) -> Result { - tracing::trace!("::shutdown: waiting for signal to trigger (read: to be cancelled)"); + tracing::info!("::shutdown: waiting for signal to trigger (read: to be cancelled)"); let weak_guard = self.guard.downgrade(); let start: time::Instant = time::Instant::now(); tokio::select! { _ = weak_guard.cancelled() => { - tracing::trace!( + tracing::info!( "::shutdown: waiting for all guards to drop for a max of {}s", limit.as_secs_f64() ); } _ = &mut self.zero_overwrite_rx => { let elapsed = start.elapsed(); - tracing::trace!("::shutdown: enforced: overwrite delayed cancellation after {}s", elapsed.as_secs_f64()); + tracing::warn!("::shutdown: enforced: overwrite delayed cancellation after {}s", elapsed.as_secs_f64()); return Err(TimeoutError(elapsed)); } }; @@ -457,17 +457,17 @@ impl Shutdown { let start: time::Instant = time::Instant::now(); tokio::select! { _ = tokio::time::sleep(limit) => { - tracing::trace!("::shutdown: timeout after {}s", limit.as_secs_f64()); + tracing::info!("::shutdown: timeout after {}s", limit.as_secs_f64()); Err(TimeoutError(limit)) } _ = self.zero_rx => { let elapsed = start.elapsed(); - tracing::trace!("::shutdown: ready after {}s", elapsed.as_secs_f64()); + tracing::info!("::shutdown: ready after {}s", elapsed.as_secs_f64()); Ok(elapsed) } _ = self.zero_overwrite_rx => { let elapsed = start.elapsed(); - tracing::trace!("::shutdown: enforced: overwrite signal triggered after {}s", elapsed.as_secs_f64()); + tracing::warn!("::shutdown: enforced: overwrite signal triggered after {}s", elapsed.as_secs_f64()); Err(TimeoutError(elapsed)) } }