use debug logging level for sql statements

This commit is contained in:
Edward Shen 2021-04-22 13:18:50 -04:00
parent 5099666322
commit 6fda24186b
Signed by: edward
GPG Key ID: 19182661E818369F

15
src/cache/low_mem.rs vendored
View File

@ -1,11 +1,13 @@
//! Low memory caching stuff //! Low memory caching stuff
use std::str::FromStr;
use std::sync::{atomic::Ordering, Arc}; use std::sync::{atomic::Ordering, Arc};
use std::{path::PathBuf, sync::atomic::AtomicU64}; use std::{path::PathBuf, sync::atomic::AtomicU64};
use async_trait::async_trait; use async_trait::async_trait;
use futures::StreamExt; use futures::StreamExt;
use sqlx::SqlitePool; use log::LevelFilter;
use sqlx::{sqlite::SqliteConnectOptions, ConnectOptions, SqlitePool};
use tokio::sync::mpsc::{channel, unbounded_channel, Sender, UnboundedSender}; use tokio::sync::mpsc::{channel, unbounded_channel, Sender, UnboundedSender};
use tokio_stream::wrappers::ReceiverStream; use tokio_stream::wrappers::ReceiverStream;
@ -33,11 +35,12 @@ impl LowMemCache {
let (file_size_tx, mut file_size_rx) = unbounded_channel(); let (file_size_tx, mut file_size_rx) = unbounded_channel();
let (db_tx, db_rx) = channel(128); let (db_tx, db_rx) = channel(128);
let db_pool = { let db_pool = {
let db_url = format!( let db_url = format!("sqlite:{}/metadata.sqlite", disk_path.to_str().unwrap());
"sqlite:{}/metadata.sqlite?mode=rwc", let mut options = SqliteConnectOptions::from_str(&db_url)
disk_path.to_str().unwrap() .unwrap()
); .create_if_missing(true);
let db = SqlitePool::connect(&db_url).await.unwrap(); options.log_statements(LevelFilter::Debug);
let db = SqlitePool::connect_with(options).await.unwrap();
// Run db init // Run db init
sqlx::query_file!("./db_queries/init.sql") sqlx::query_file!("./db_queries/init.sql")