It seems there is code that should log the pool acquire times, but whatever settings I try I does not log anything.
I tried using env_logger and tracing_subscriber (both set to max log level trace) but both only log statements from the sqlx::query package. Trace logs of other (non-sqlx) crates are written to stdout, so I guess its a problem with the logging logic in sqlx::pool?
Minimal Reproduction
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
#[tokio::main]
async fn main() {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.init();
let pool = SqlitePoolOptions::new()
.max_connections(1)
.connect_with(
SqliteConnectOptions::new()
.filename("test.db")
.create_if_missing(true)
.to_owned(),
)
.await
.expect("failed to create pool for database");
sqlx::query(
r#"
CREATE TABLE IF NOT EXISTS dummy (
id INTEGER NOT NULL PRIMARY KEY,
value INTEGER
)
"#,
)
.execute(&pool)
.await
.expect("failed to create dummy table");
let pool2 = pool.clone();
tokio::spawn(async move {
loop {
insert_dummy_data(&pool2).await;
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
});
tokio::spawn(async move {
loop {
insert_dummy_data(&pool).await;
tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
}
});
tokio::time::sleep(tokio::time::Duration::from_secs(20)).await;
}
async fn insert_dummy_data(pool: &sqlx::SqlitePool) {
let random = rand::random::<u8>();
sqlx::query("INSERT INTO dummy (value) VALUES (?)")
.bind(random)
.execute(pool)
.await
.expect("failed to insert dummy data");
}
When running this example code (all with latest versions of the used crates), the only logging you will get is this:
Bug Description
It seems there is code that should log the pool acquire times, but whatever settings I try I does not log anything.
I tried using
env_logger
andtracing_subscriber
(both set to max log leveltrace
) but both only log statements from thesqlx::query
package. Trace logs of other (non-sqlx) crates are written to stdout, so I guess its a problem with the logging logic insqlx::pool
?Minimal Reproduction
When running this example code (all with latest versions of the used crates), the only logging you will get is this:
Info
rustc --version
: rustc 1.82.0 (f6e511eec 2024-10-15)