From d9a999a578a9574de478261dca845bbefb3772d8 Mon Sep 17 00:00:00 2001 From: "Michael P. Jung" Date: Mon, 16 Dec 2019 14:36:23 +0100 Subject: [PATCH] Add back logging of queries This fixes #492 --- tokio-postgres/src/query.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tokio-postgres/src/query.rs b/tokio-postgres/src/query.rs index 76d14e5cc..a821caf89 100644 --- a/tokio-postgres/src/query.rs +++ b/tokio-postgres/src/query.rs @@ -21,7 +21,17 @@ where I: IntoIterator, I::IntoIter: ExactSizeIterator, { - let buf = encode(client, &statement, params)?; + let buf = if log::log_enabled!(log::Level::Debug) { + let params = params.into_iter().collect::>(); + log::debug!( + "executing statement {} with parameters: {:?}", + statement.name(), + params, + ); + encode(client, &statement, params)? + } else { + encode(client, &statement, params)? + }; let responses = start(client, buf).await?; Ok(RowStream { statement, @@ -59,7 +69,17 @@ where I: IntoIterator, I::IntoIter: ExactSizeIterator, { - let buf = encode(client, &statement, params)?; + let buf = if log::log_enabled!(log::Level::Debug) { + let params = params.into_iter().collect::>(); + log::debug!( + "executing statement {} with parameters: {:?}", + statement.name(), + params, + ); + encode(client, &statement, params)? + } else { + encode(client, &statement, params)? + }; let mut responses = start(client, buf).await?; loop {