mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-02-15 04:09:37 +00:00
Extract slow query threshold to constant
This commit is contained in:
parent
627d8292f8
commit
581bcf0ceb
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user