From 581bcf0ceb3e9f512fb2189aa40c1e6940020dc1 Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Tue, 21 Apr 2020 21:35:59 -0400 Subject: [PATCH] Extract slow query threshold to constant --- sqlx-core/src/logging.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sqlx-core/src/logging.rs b/sqlx-core/src/logging.rs index 8010992771..d81cbc027a 100644 --- a/sqlx-core/src/logging.rs +++ b/sqlx-core/src/logging.rs @@ -1,3 +1,7 @@ +use std::time::Duration; + +pub(crate) const SLOW_QUERY_THRESHOLD: Duration = Duration::from_secs(1); + /// Logs the query and execution time of a statement as it runs. macro_rules! log_execution { ( $query:expr, $block:expr ) => {{ @@ -6,7 +10,7 @@ macro_rules! log_execution { let timer = std::time::Instant::now(); let result = $block; let elapsed = timer.elapsed(); - if elapsed >= std::time::Duration::from_secs(1) { + if elapsed >= crate::logging::SLOW_QUERY_THRESHOLD { log::warn!( target: "sqlx::query", "{} ..., elapsed: {:.3?}\n\n{}\n",