From 7fcc188041f7776eaeb7d1d9f68b1cc3edad55f2 Mon Sep 17 00:00:00 2001 From: Andrej Mihajlov Date: Tue, 3 Jun 2025 17:19:42 +0200 Subject: [PATCH] Switch to tracing --- Cargo.lock | 2 +- sqlx-pool-guard/Cargo.toml | 2 +- sqlx-pool-guard/src/apple.rs | 4 ++-- sqlx-pool-guard/src/lib.rs | 8 ++++---- sqlx-pool-guard/src/linux.rs | 4 ++-- sqlx-pool-guard/src/windows.rs | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 508eb70645..08fc8c0c70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9540,11 +9540,11 @@ dependencies = [ name = "sqlx-pool-guard" version = "0.1.0" dependencies = [ - "log", "proc_pidinfo", "sqlx", "tempfile", "tokio", + "tracing", "windows 0.61.1", ] diff --git a/sqlx-pool-guard/Cargo.toml b/sqlx-pool-guard/Cargo.toml index a77ee80024..86c57a5277 100644 --- a/sqlx-pool-guard/Cargo.toml +++ b/sqlx-pool-guard/Cargo.toml @@ -15,7 +15,7 @@ tokio = { workspace = true, features = [ "fs", ] } sqlx = { workspace = true, features = ["runtime-tokio-rustls", "sqlite"] } -log.workspace = true +tracing.workspace = true [target.'cfg(target_os = "macos")'.dependencies] proc_pidinfo.workspace = true diff --git a/sqlx-pool-guard/src/apple.rs b/sqlx-pool-guard/src/apple.rs index 549839a550..a67ed1a447 100644 --- a/sqlx-pool-guard/src/apple.rs +++ b/sqlx-pool-guard/src/apple.rs @@ -20,7 +20,7 @@ pub async fn check_files_closed(file_paths: &[&Path]) -> io::Result { { let Some(vnode) = proc_pidfdinfo_self::(fd.proc_fd) .inspect_err(|e| { - log::warn!("proc_pidfdinfo_self::() failure: {e}"); + tracing::warn!("proc_pidfdinfo_self::() failure: {e}"); }) .ok() .flatten() @@ -32,7 +32,7 @@ pub async fn check_files_closed(file_paths: &[&Path]) -> io::Result { .path() .map(|vnode_path| file_paths.contains(&vnode_path)) .inspect_err(|e| { - log::warn!("vnode.path() failure: {e:?}"); + tracing::warn!("vnode.path() failure: {e:?}"); }) { return Ok(false); diff --git a/sqlx-pool-guard/src/lib.rs b/sqlx-pool-guard/src/lib.rs index 6f01b2b55c..fc5169b519 100644 --- a/sqlx-pool-guard/src/lib.rs +++ b/sqlx-pool-guard/src/lib.rs @@ -55,7 +55,7 @@ impl SqlitePoolGuard { pub async fn close(&self) { // Avoid waiting for db files once the pool is marked closed to ensure that we don't wait on some other sqlite pool to close the database. if !self.connection_pool.is_closed() { - log::info!("Closing sqlite pool: {}", self.database_path.display()); + tracing::info!("Closing sqlite pool: {}", self.database_path.display()); _ = self.close_pool_inner(); } } @@ -64,7 +64,7 @@ impl SqlitePoolGuard { self.connection_pool.close().await; if let Err(e) = self.wait_for_db_files_close().await { - log::error!("Failed to wait for file to close: {e}"); + tracing::error!("Failed to wait for file to close: {e}"); } Ok(()) @@ -77,7 +77,7 @@ impl SqlitePoolGuard { .database_path .canonicalize() .inspect_err(|e| { - log::error!( + tracing::error!( "Failed to canonicalize path: {}. Cause: {e}", self.database_path.display() ); @@ -103,7 +103,7 @@ impl SqlitePoolGuard { for _ in 0..CHECK_FILES_CLOSED_MAX_ATTEMPTS { match imp::check_files_closed(&paths) .await - .inspect_err(|e| log::error!("imp::check_files_closed() failure: {e}")) + .inspect_err(|e| tracing::error!("imp::check_files_closed() failure: {e}")) { Ok(false) | Err(_) => tokio::time::sleep(CHECK_FILES_CLOSED_RETRY_DELAY).await, Ok(true) => return Ok(()), diff --git a/sqlx-pool-guard/src/linux.rs b/sqlx-pool-guard/src/linux.rs index f7610e67c5..e0f26de9e5 100644 --- a/sqlx-pool-guard/src/linux.rs +++ b/sqlx-pool-guard/src/linux.rs @@ -16,7 +16,7 @@ pub async fn check_files_closed(file_paths: &[&Path]) -> io::Result { if entry .file_type() .await - .inspect_err(|e| log::warn!("entry.file_type() failure: {e}")) + .inspect_err(|e| tracing::warn!("entry.file_type() failure: {e}")) .is_ok_and(|entry_type| entry_type.is_symlink()) { match tokio::fs::read_link(entry.path()).await { @@ -26,7 +26,7 @@ pub async fn check_files_closed(file_paths: &[&Path]) -> io::Result { } } Err(e) => { - log::error!("Failed to read symlink: {e}"); + tracing::error!("Failed to read symlink: {e}"); } } } diff --git a/sqlx-pool-guard/src/windows.rs b/sqlx-pool-guard/src/windows.rs index 4fca6c1bef..799eac2abe 100644 --- a/sqlx-pool-guard/src/windows.rs +++ b/sqlx-pool-guard/src/windows.rs @@ -57,7 +57,7 @@ pub async fn check_files_closed(file_paths: &[&Path]) -> io::Result { // Buffer is too small, resize memory and retry again. if status == STATUS_INFO_LENGTH_MISMATCH { - log::trace!("Buffer is too small ({reserved_memory}), resizing to {return_len}"); + tracing::trace!("Buffer is too small ({reserved_memory}), resizing to {return_len}"); reserved_memory = return_len as usize; handle_table_info.reallocate(reserved_memory)?; } else {